2014-01-28 19:41:21 +11:00
using System ;
using System.Collections.Generic ;
2014-02-10 16:22:15 +11:00
using System.ComponentModel ;
2013-08-28 17:52:06 +02:00
using System.ComponentModel.DataAnnotations ;
using System.Linq ;
2014-01-28 19:41:21 +11:00
using System.Web ;
2014-03-11 14:23:51 +11:00
using System.Xml ;
using System.Xml.Linq ;
2013-08-28 17:52:06 +02:00
using umbraco.cms.businesslogic.member ;
2014-01-28 19:41:21 +11:00
using Umbraco.Core ;
2014-03-11 14:23:51 +11:00
using Umbraco.Core.Models ;
using Umbraco.Core.Models.PublishedContent ;
using Umbraco.Web.PublishedCache ;
2014-01-28 19:41:21 +11:00
using Umbraco.Web.Security ;
2013-08-28 17:52:06 +02:00
namespace Umbraco.Web.Models
{
2014-03-11 14:23:51 +11:00
/// <summary>
/// A readonly member profile model
/// </summary>
2014-02-13 13:30:32 +11:00
public class ProfileModel : PostRedirectModel
2013-08-28 17:52:06 +02:00
{
2014-03-11 14:23:51 +11:00
2014-01-28 19:41:21 +11:00
public static ProfileModel CreateModel ( )
2013-08-28 17:52:06 +02:00
{
2014-01-28 19:41:21 +11:00
var model = new ProfileModel ( false ) ;
return model ;
}
2013-08-28 17:52:06 +02:00
2014-01-28 19:41:21 +11:00
private ProfileModel ( bool doLookup )
{
MemberProperties = new List < UmbracoProperty > ( ) ;
if ( doLookup )
{
var helper = new MembershipHelper ( ApplicationContext . Current , new HttpContextWrapper ( HttpContext . Current ) ) ;
2014-03-11 14:23:51 +11:00
var model = helper . GetCurrentMemberProfileModel ( ) ;
2014-01-28 19:41:21 +11:00
MemberProperties = model . MemberProperties ;
}
}
2013-08-28 17:52:06 +02:00
2014-01-28 19:41:21 +11:00
[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-08-28 17:52:06 +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-10 16:22:15 +11:00
/// <summary>
/// The member's real name
/// </summary>
2013-08-28 17:52:06 +02:00
public string Name { get ; set ; }
2014-02-10 16:22:15 +11:00
/// <summary>
/// The member's member type alias
/// </summary>
[ReadOnly(true)]
2013-08-28 17:52:06 +02:00
public string MemberTypeAlias { get ; set ; }
2014-02-19 16:27:14 +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-10 16:22:15 +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>
2014-03-11 14:23:51 +11:00
public List < UmbracoProperty > MemberProperties { get ; set ; }
2013-08-28 17:52:06 +02:00
}
}