2014-02-13 16:22:51 +11:00
using System ;
using System.Collections.Generic ;
using System.ComponentModel ;
2013-09-02 15:40:14 +02:00
using System.ComponentModel.DataAnnotations ;
using System.Linq ;
2014-02-13 16:22:51 +11:00
using System.Web ;
2013-09-02 15:40:14 +02:00
using umbraco.cms.businesslogic.member ;
2014-02-13 16:22:51 +11:00
using Umbraco.Core ;
using Umbraco.Web.Security ;
2013-09-02 15:40:14 +02:00
namespace Umbraco.Web.Models
{
2014-02-13 16:22:51 +11:00
public class ProfileModel : PostRedirectModel
2013-09-02 15:40:14 +02:00
{
2014-02-13 16:22:51 +11:00
public static ProfileModel CreateModel ( )
2013-09-02 15:40:14 +02:00
{
2014-02-13 16:22:51 +11:00
var model = new ProfileModel ( false ) ;
return model ;
}
private ProfileModel ( bool doLookup )
{
MemberProperties = new List < UmbracoProperty > ( ) ;
if ( doLookup )
2013-09-02 15:40:14 +02:00
{
2014-02-13 16:22:51 +11:00
var helper = new MembershipHelper ( ApplicationContext . Current , new HttpContextWrapper ( HttpContext . Current ) ) ;
2014-03-11 10:39:19 +11:00
var model = helper . GetCurrentMemberProfile ( ) ;
2014-02-13 16:22:51 +11:00
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 )
{
2013-09-02 15:40:14 +02:00
}
[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 ; }
2014-02-13 16:22:51 +11:00
/// <summary>
/// The member's real name
/// </summary>
2013-09-02 15:40:14 +02:00
public string Name { get ; set ; }
2014-02-13 16:22:51 +11:00
/// <summary>
/// The member's member type alias
/// </summary>
[ReadOnly(true)]
[Obsolete("This is not used and will be removed from the codebase in future versions")]
2013-09-02 15:40:14 +02:00
public string MemberTypeAlias { get ; set ; }
2014-02-19 16:55:56 +11:00
[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 ; }
2014-02-13 16:22:51 +11:00
/// <summary>
/// The list of member properties
/// </summary>
/// <remarks>
/// Adding items to this list on the front-end will not add properties to the member in the database.
/// </remarks>
2013-09-02 15:40:14 +02:00
public List < UmbracoProperty > MemberProperties { get ; set ; }
2014-02-13 16:22:51 +11:00
2013-09-02 15:40:14 +02:00
}
}