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 ;
2013-08-28 17:52:06 +02:00
using umbraco.cms.businesslogic.member ;
2014-01-28 19:41:21 +11:00
using Umbraco.Core ;
using Umbraco.Web.Security ;
2013-08-28 17:52:06 +02:00
namespace Umbraco.Web.Models
{
public class ProfileModel
{
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 ) ) ;
var model = helper . CreateProfileModel ( ) ;
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)]
[Obsolete("This is not used and will be removed from the codebase in future versions")]
2013-08-28 17:52:06 +02:00
public string MemberTypeAlias { 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>
2013-08-28 17:52:06 +02:00
public List < UmbracoProperty > MemberProperties { get ; set ; }
}
}