using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web; using umbraco.cms.businesslogic.member; using Umbraco.Core; using Umbraco.Web.Security; namespace Umbraco.Web.Models { public class ProfileModel : PostRedirectModel { public static ProfileModel CreateModel() { var model = new ProfileModel(false); return model; } private ProfileModel(bool doLookup) { MemberProperties = new List(); if (doLookup) { var helper = new MembershipHelper(ApplicationContext.Current, new HttpContextWrapper(HttpContext.Current)); var model = helper.GetCurrentMemberProfile(); MemberProperties = model.MemberProperties; } } [Obsolete("Do not use this ctor as it will perform business logic lookups. Use the MembershipHelper.CreateProfileModel or the static ProfileModel.CreateModel() to create an empty model.")] public ProfileModel() :this(true) { } [Required] [RegularExpression(@"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", ErrorMessage = "Please enter a valid e-mail address")] public string Email { get; set; } /// /// The member's real name /// public string Name { get; set; } /// /// The member's member type alias /// [ReadOnly(true)] [Obsolete("This is not used and will be removed from the codebase in future versions")] public string MemberTypeAlias { get; set; } [ReadOnly(true)] public string UserName { get; set; } [ReadOnly(true)] public string PasswordQuestion { get; set; } [ReadOnly(true)] public string Comment { get; set; } [ReadOnly(true)] public bool IsApproved { get; set; } [ReadOnly(true)] public bool IsLockedOut { get; set; } [ReadOnly(true)] public DateTime LastLockoutDate { get; set; } [ReadOnly(true)] public DateTime CreationDate { get; set; } [ReadOnly(true)] public DateTime LastLoginDate { get; set; } [ReadOnly(true)] public DateTime LastActivityDate { get; set; } [ReadOnly(true)] public DateTime LastPasswordChangedDate { get; set; } /// /// The list of member properties /// /// /// Adding items to this list on the front-end will not add properties to the member in the database. /// public List MemberProperties { get; set; } } }