<commit_before>﻿/*
 * Beethoven.Plugins
 * 
 * Written for .NET 4.0 in C#
 * 
 * Copyright (C) 2009, 2010, 2011. All Right Reserved, Spartansoft L.L.C.
 * http://spartansoft.org
 * 
 * Proprietary and Confidential information of Spartansoft L.L.C. 
 * Redistribution and use in source and binary forms, with or without modification, 
 * without the authorization of Spartansoft L.L.C.  is prohibited. * 
 * 
 * "Whatever happens SPARTAN's code must stand ... or at least crash responsibly."
 *  
 * File Name: UserProfile.cs
 * 
 * File Authors:
 * 		<NAME>, <EMAIL>
 * 
 * Date Created:
 *      04.08.2011 06:13 AM
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Profile;
using System.Web;
using Beethoven.Plugins.Helpers;
using Beethoven.Plugins.ViewModels;

namespace Beethoven.Plugins.Account
{
    public class UserProfile : ProfileBase
    {
        public static UserProfile CurrentUser
        {
            get
            {
                if (System.Web.Security.Membership.GetUser() != null)
                    return ProfileBase.Create(System.Web.Security.Membership.GetUser().UserName) as UserProfile;
                else
                    return null;

            }
        }

        public static ProfileViewModel GetProfile()
        {
            return new ProfileViewModel
            {
                UserName = CurrentUser.UserName,
                FullName = CurrentUser.FullName,
                Email = CurrentUser.Email,
                Phone = CurrentUser.Phone,
                Gravatar = CurrentUser.Gravatar
            };
        }

        public static UserProfile GetUser(string username)
        {                           
                System.Web.Security.MembershipUser user = System.Web.Security.Membership.GetUser(username);
                return ProfileBase.Create(user.UserName, true) as UserProfile;
           
        }

        public static UserProfile NewUser
        {
            get { return System.Web.HttpContext.Current.Profile as UserProfile; }
        }


        public string FullName
        {
            get { return ((string)(base["FullName"])); }
            set { base["FullName"] = value; Save(); }
        }

        public string Email
        {
            get { return ((string)(base["Email"])); }
            set { base["Email"] = value; Save(); }<commit_msg>return new ProfileViewModel if cannot get current logged in user.<commit_after>﻿/*
 * Beethoven.Plugins
 * 
 * Written for .NET 4.0 in C#
 * 
 * Copyright (C) 2009, 2010, 2011. All Right Reserved, Spartansoft L.L.C.
 * http://spartansoft.org
 * 
 * Proprietary and Confidential information of Spartansoft L.L.C. 
 * Redistribution and use in source and binary forms, with or without modification, 
 * without the authorization of Spartansoft L.L.C.  is prohibited. * 
 * 
 * "Whatever happens SPARTAN's code must stand ... or at least crash responsibly."
 *  
 * File Name: UserProfile.cs
 * 
 * File Authors:
 * 		<NAME>, <EMAIL>
 * 
 * Date Created:
 *      04.08.2011 06:13 AM
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Profile;
using System.Web;
using Beethoven.Plugins.Helpers;
using Beethoven.Plugins.ViewModels;

namespace Beethoven.Plugins.Account
{
    public class UserProfile : ProfileBase
    {
        public static UserProfile CurrentUser
        {
            get
            {
                if (System.Web.Security.Membership.GetUser() != null)
                    return ProfileBase.Create(System.Web.Security.Membership.GetUser().UserName) as UserProfile;
                else
                    return null;

            }
        }

        public static ProfileViewModel GetProfile()
        {
            if (CurrentUser != null)
                return new ProfileViewModel
                {
                    UserName = CurrentUser.UserName,
                    FullName = CurrentUser.FullName,
                    Email = CurrentUser.Email,
                    Phone = CurrentUser.Phone,
                    Gravatar = CurrentUser.Gravatar
                };
            else
                return new ProfileViewModel();
        }

        public static UserProfile GetUser(string username)
        {                           
                System.Web.Security.MembershipUser user = System.Web.Security.Membership.GetUser(username);
                return ProfileBase.Create(user.UserName, true) as UserProfile;
           
        }

        public static UserProfile NewUser
        {
            get { return System.Web.HttpContext.Current.Profile as UserProfile; }
        }


        public string FullName
        {
            get { return ((string)(base["FullName"])); }
            set { base["FullName"] = value; Save(); }
        }

        public string Email
        {
            get { return ((string)(base["Email"])); }
            set { base["Email"] = value; Save(); }
{'fraction_non_alphanumeric': 0.09231386714830424, 'fraction_numerical': 0.01043548063415613, 'mean_word_length': 1.8205998868138087, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5522888', 'n_tokens_mistral': 1398, 'n_tokens_neox': 1273, 'n_words': 347}