diff --git a/src/Umbraco.Core/Constants-Conventions.cs b/src/Umbraco.Core/Constants-Conventions.cs
index df34b2ca4f..b8161b9480 100644
--- a/src/Umbraco.Core/Constants-Conventions.cs
+++ b/src/Umbraco.Core/Constants-Conventions.cs
@@ -1,4 +1,8 @@
-namespace Umbraco.Core
+using System;
+using System.Collections.Generic;
+using Umbraco.Core.Models;
+
+namespace Umbraco.Core
{
public static partial class Constants
{
@@ -90,6 +94,210 @@
public const string Image = "Image";
}
+ ///
+ /// Constants for Umbraco Member property aliases.
+ ///
+ public static class Member
+ {
+ ///
+ /// Property alias for a Members Password Question
+ ///
+ public const string PasswordQuestion = "umbracoPasswordRetrievalQuestionPropertyTypeAlias";
+
+ public const string PasswordQuestionLabel = "Password Question";
+
+ ///
+ /// Property alias for Members Password Answer
+ ///
+ public const string PasswordAnswer = "umbracoPasswordRetrievalAnswerPropertyTypeAlias";
+
+ public const string PasswordAnswerLabel = "Password Answer";
+
+ ///
+ /// Property alias for the Comments on a Member
+ ///
+ public const string Comments = "umbracoCommentPropertyTypeAlias";
+
+ public const string CommentsLabel = "Comments";
+
+ ///
+ /// Property alias for the Approved boolean of a Member
+ ///
+ public const string IsApproved = "umbracoApprovePropertyTypeAlias";
+
+ public const string IsApprovedLabel = "Is Approved";
+
+ ///
+ /// Property alias for the Locked out boolean of a Member
+ ///
+ public const string IsLockedOut = "umbracoLockPropertyTypeAlias";
+
+ public const string IsLockedOutLabel = "Is Locked Out";
+
+ ///
+ /// Property alias for the last date the Member logged in
+ ///
+ public const string LastLoginDate = "umbracoLastLoginPropertyTypeAlias";
+
+ public const string LastLoginDateLabel = "Last Login Date";
+
+ ///
+ /// Property alias for the last date a Member changed its password
+ ///
+ public const string LastPasswordChangeDate = "umbracoMemberLastPasswordChange";
+
+ public const string LastPasswordChangeDateLabel = "Last Password Change Date";
+
+ ///
+ /// Property alias for the last date a Member was locked out
+ ///
+ public const string LastLockoutDate = "umbracoMemberLastLockout";
+
+ public const string LastLockoutDateLabel = "Last Lockout Date";
+
+ ///
+ /// Property alias for the number of failed login attemps
+ ///
+ public const string FailedPasswordAttempts = "umbracoFailedPasswordAttemptsPropertyTypeAlias";
+
+ public const string FailedPasswordAttemptsLabel = "Failed Password Attempts";
+
+ internal static Dictionary
+ StandardPropertyTypeStubs = new Dictionary
+ {
+ {
+ Comments,
+ new PropertyType(
+ new Guid(
+ PropertyEditors
+ .TextboxMultiple),
+ DataTypeDatabaseType
+ .Ntext)
+ {
+ Alias = Comments,
+ Name =
+ CommentsLabel
+ }
+ },
+ {
+ FailedPasswordAttempts,
+ new PropertyType(
+ new Guid(
+ PropertyEditors
+ .Integer),
+ DataTypeDatabaseType
+ .Integer)
+ {
+ Alias =
+ FailedPasswordAttempts,
+ Name =
+ FailedPasswordAttemptsLabel
+ }
+ },
+ {
+ IsApproved,
+ new PropertyType(
+ new Guid(
+ PropertyEditors
+ .TrueFalse),
+ DataTypeDatabaseType
+ .Integer)
+ {
+ Alias = IsApproved,
+ Name =
+ IsApprovedLabel
+ }
+ },
+ {
+ IsLockedOut,
+ new PropertyType(
+ new Guid(
+ PropertyEditors
+ .TrueFalse),
+ DataTypeDatabaseType
+ .Integer)
+ {
+ Alias =
+ IsLockedOut,
+ Name =
+ IsLockedOutLabel
+ }
+ },
+ {
+ LastLockoutDate,
+ new PropertyType(
+ new Guid(
+ PropertyEditors.Date),
+ DataTypeDatabaseType
+ .Date)
+ {
+ Alias =
+ LastLockoutDate,
+ Name =
+ LastLockoutDateLabel
+ }
+ },
+ {
+ LastLoginDate,
+ new PropertyType(
+ new Guid(
+ PropertyEditors.Date),
+ DataTypeDatabaseType
+ .Date)
+ {
+ Alias =
+ LastLoginDate,
+ Name =
+ LastLoginDateLabel
+ }
+ },
+ {
+ LastPasswordChangeDate,
+ new PropertyType(
+ new Guid(
+ PropertyEditors.Date),
+ DataTypeDatabaseType
+ .Date)
+ {
+ Alias =
+ LastPasswordChangeDate,
+ Name =
+ LastPasswordChangeDateLabel
+ }
+ },
+ {
+ PasswordAnswer,
+ new PropertyType(
+ new Guid(
+ PropertyEditors
+ .Textbox),
+ DataTypeDatabaseType
+ .Nvarchar)
+ {
+ Alias =
+ PasswordAnswer,
+ Name =
+ PasswordAnswerLabel
+ }
+ },
+ {
+ PasswordQuestion,
+ new PropertyType(
+ new Guid(
+ PropertyEditors
+ .Textbox),
+ DataTypeDatabaseType
+ .Nvarchar)
+ {
+ Alias =
+ PasswordQuestion,
+ Name =
+ PasswordQuestionLabel
+ }
+ }
+ };
+ }
+
///
/// Defines the alias identifiers for Umbraco member types.
///
diff --git a/src/Umbraco.Core/Models/Content.cs b/src/Umbraco.Core/Models/Content.cs
index be6fd9543a..2223d45cd8 100644
--- a/src/Umbraco.Core/Models/Content.cs
+++ b/src/Umbraco.Core/Models/Content.cs
@@ -1,9 +1,7 @@
using System;
-using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
-using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
diff --git a/src/Umbraco.Core/Models/IContentType.cs b/src/Umbraco.Core/Models/IContentType.cs
index c8cba83a37..3e61b98510 100644
--- a/src/Umbraco.Core/Models/IContentType.cs
+++ b/src/Umbraco.Core/Models/IContentType.cs
@@ -1,5 +1,4 @@
using System.Collections.Generic;
-using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
diff --git a/src/Umbraco.Core/Models/IMember.cs b/src/Umbraco.Core/Models/IMember.cs
new file mode 100644
index 0000000000..0b347a2515
--- /dev/null
+++ b/src/Umbraco.Core/Models/IMember.cs
@@ -0,0 +1,114 @@
+using System;
+
+namespace Umbraco.Core.Models
+{
+ public interface IMember : IContentBase
+ {
+ ///
+ /// Gets or sets the Username
+ ///
+ string Username { get; set; }
+
+ ///
+ /// Gets or sets the Email
+ ///
+ string Email { get; set; }
+
+ ///
+ /// Gets or sets the Password
+ ///
+ string Password { get; set; }
+
+ ///
+ /// Gets or sets the Password Question
+ ///
+ ///
+ /// Alias: umbracoPasswordRetrievalQuestionPropertyTypeAlias
+ /// Part of the standard properties collection.
+ ///
+ string PasswordQuestion { get; set; }
+
+ ///
+ /// Gets or sets the Password Answer
+ ///
+ ///
+ /// Alias: umbracoPasswordRetrievalAnswerPropertyTypeAlias
+ /// Part of the standard properties collection.
+ ///
+ string PasswordAnswer { get; set; }
+
+ ///
+ /// Gets or set the comments for the member
+ ///
+ ///
+ /// Alias: umbracoCommentPropertyTypeAlias
+ /// Part of the standard properties collection.
+ ///
+ string Comments { get; set; }
+
+ ///
+ /// Gets or sets a boolean indicating whether the Member is approved
+ ///
+ ///
+ /// Alias: umbracoApprovePropertyTypeAlias
+ /// Part of the standard properties collection.
+ ///
+ bool IsApproved { get; set; }
+
+ ///
+ /// Gets or sets a boolean indicating whether the Member is locked out
+ ///
+ ///
+ /// Alias: umbracoLockPropertyTypeAlias
+ /// Part of the standard properties collection.
+ ///
+ bool IsLockedOut { get; set; }
+
+ ///
+ /// Gets or sets the date for last login
+ ///
+ ///
+ /// Alias: umbracoLastLoginPropertyTypeAlias
+ /// Part of the standard properties collection.
+ ///
+ DateTime LastLoginDate { get; set; }
+
+ ///
+ /// Gest or sets the date for last password change
+ ///
+ ///
+ /// Alias: umbracoMemberLastPasswordChange
+ /// Part of the standard properties collection.
+ ///
+ DateTime LastPasswordChangeDate { get; set; }
+
+ ///
+ /// Gets or sets the date for when Member was locked out
+ ///
+ ///
+ /// Alias: umbracoMemberLastLockout
+ /// Part of the standard properties collection.
+ ///
+ DateTime LastLockoutDate { get; set; }
+
+ ///
+ /// Gets or sets the number of failed password attempts.
+ /// This is the number of times the password was entered incorrectly upon login.
+ ///
+ ///
+ /// Alias: umbracoFailedPasswordAttemptsPropertyTypeAlias
+ /// Part of the standard properties collection.
+ ///
+ int FailedPasswordAttempts { get; set; }
+
+ ///
+ /// String alias of the default ContentType
+ ///
+ string ContentTypeAlias { get; }
+
+ ///
+ /// Gets the ContentType used by this content object
+ ///
+ IMemberType ContentType { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Models/IMemberType.cs b/src/Umbraco.Core/Models/IMemberType.cs
new file mode 100644
index 0000000000..8f39e96801
--- /dev/null
+++ b/src/Umbraco.Core/Models/IMemberType.cs
@@ -0,0 +1,36 @@
+namespace Umbraco.Core.Models
+{
+ ///
+ /// Defines a MemberType, which Member is based on
+ ///
+ public interface IMemberType : IContentTypeComposition
+ {
+ ///
+ /// Gets a boolean indicating whether a Property is editable by the Member.
+ ///
+ /// PropertyType Alias of the Property to check
+ ///
+ bool MemberCanEditProperty(string propertyTypeAlias);
+
+ ///
+ /// Gets a boolean indicating whether a Property is visible on the Members profile.
+ ///
+ /// PropertyType Alias of the Property to check
+ ///
+ bool MemberCanViewProperty(string propertyTypeAlias);
+
+ ///
+ /// Sets a boolean indicating whether a Property is editable by the Member.
+ ///
+ /// PropertyType Alias of the Property to set
+ /// Boolean value, true or false
+ void SetMemberCanEditProperty(string propertyTypeAlias, bool value);
+
+ ///
+ /// Sets a boolean indicating whether a Property is visible on the Members profile.
+ ///
+ /// PropertyType Alias of the Property to set
+ /// Boolean value, true or false
+ void SetMemberCanViewProperty(string propertyTypeAlias, bool value);
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Models/Member.cs b/src/Umbraco.Core/Models/Member.cs
new file mode 100644
index 0000000000..b3baac8351
--- /dev/null
+++ b/src/Umbraco.Core/Models/Member.cs
@@ -0,0 +1,436 @@
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Runtime.Serialization;
+
+namespace Umbraco.Core.Models
+{
+ ///
+ /// Represents a Member object
+ ///
+ [Serializable]
+ [DataContract(IsReference = true)]
+ public class Member : ContentBase, IMember
+ {
+ private readonly IMemberType _contentType;
+ private string _contentTypeAlias;
+ private string _username;
+ private string _email;
+ private string _password;
+ private object _providerUserKey;
+ private Type _userTypeKey;
+
+ public Member(string name, int parentId, IMemberType contentType, PropertyCollection properties) : base(name, parentId, contentType, properties)
+ {
+ Mandate.ParameterNotNull(contentType, "contentType");
+
+ _contentType = contentType;
+ }
+
+ public Member(string name, IContentBase parent, IMemberType contentType, PropertyCollection properties)
+ : base(name, parent, contentType, properties)
+ {
+ Mandate.ParameterNotNull(contentType, "contentType");
+
+ _contentType = contentType;
+ }
+
+ private static readonly PropertyInfo DefaultContentTypeAliasSelector = ExpressionHelper.GetPropertyInfo(x => x.ContentTypeAlias);
+ private static readonly PropertyInfo UsernameSelector = ExpressionHelper.GetPropertyInfo(x => x.Username);
+ private static readonly PropertyInfo EmailSelector = ExpressionHelper.GetPropertyInfo(x => x.Email);
+ private static readonly PropertyInfo PasswordSelector = ExpressionHelper.GetPropertyInfo(x => x.Password);
+ private static readonly PropertyInfo ProviderUserKeySelector = ExpressionHelper.GetPropertyInfo(x => x.ProviderUserKey);
+ private static readonly PropertyInfo UserTypeKeySelector = ExpressionHelper.GetPropertyInfo(x => x.ProviderUserKeyType);
+
+ ///
+ /// Gets or sets the Username
+ ///
+ [DataMember]
+ public string Username
+ {
+ get { return _username; }
+ set
+ {
+ SetPropertyValueAndDetectChanges(o =>
+ {
+ _username = value;
+ return _username;
+ }, _username, UsernameSelector);
+ }
+ }
+
+ ///
+ /// Gets or sets the Email
+ ///
+ [DataMember]
+ public string Email
+ {
+ get { return _email; }
+ set
+ {
+ SetPropertyValueAndDetectChanges(o =>
+ {
+ _email = value;
+ return _email;
+ }, _email, EmailSelector);
+ }
+ }
+
+ ///
+ /// Gets or sets the Password
+ ///
+ [DataMember]
+ public string Password
+ {
+ get { return _password; }
+ set
+ {
+ SetPropertyValueAndDetectChanges(o =>
+ {
+ _password = value;
+ return _password;
+ }, _password, PasswordSelector);
+ }
+ }
+
+ ///
+ /// Gets or sets the Groups that Member is part of
+ ///
+ [DataMember]
+ public IEnumerable Groups { get; set; }
+
+ ///
+ /// Gets or sets the Password Question
+ ///
+ ///
+ /// Alias: umbracoPasswordRetrievalQuestionPropertyTypeAlias
+ /// Part of the standard properties collection.
+ ///
+ [IgnoreDataMember]
+ public string PasswordQuestion
+ {
+ get
+ {
+ return Properties[Constants.Conventions.Member.PasswordQuestion].Value == null
+ ? string.Empty
+ : Properties[Constants.Conventions.Member.PasswordQuestion].Value.ToString();
+ }
+ set
+ {
+ Properties[Constants.Conventions.Member.PasswordQuestion].Value = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the Password Answer
+ ///
+ ///
+ /// Alias: umbracoPasswordRetrievalAnswerPropertyTypeAlias
+ /// Part of the standard properties collection.
+ ///
+ [IgnoreDataMember]
+ public string PasswordAnswer
+ {
+ get
+ {
+ return Properties[Constants.Conventions.Member.PasswordAnswer].Value == null
+ ? string.Empty
+ : Properties[Constants.Conventions.Member.PasswordAnswer].Value.ToString();
+ }
+ set
+ {
+ Properties[Constants.Conventions.Member.PasswordAnswer].Value = value;
+ }
+ }
+
+ ///
+ /// Gets or set the comments for the member
+ ///
+ ///
+ /// Alias: umbracoCommentPropertyTypeAlias
+ /// Part of the standard properties collection.
+ ///
+ [IgnoreDataMember]
+ public string Comments
+ {
+ get
+ {
+ return Properties[Constants.Conventions.Member.Comments].Value == null
+ ? string.Empty
+ : Properties[Constants.Conventions.Member.Comments].Value.ToString();
+ }
+ set
+ {
+ Properties[Constants.Conventions.Member.Comments].Value = value;
+ }
+ }
+
+ ///
+ /// Gets or sets a boolean indicating whether the Member is approved
+ ///
+ ///
+ /// Alias: umbracoApprovePropertyTypeAlias
+ /// Part of the standard properties collection.
+ ///
+ [IgnoreDataMember]
+ public bool IsApproved
+ {
+ get
+ {
+ if (Properties[Constants.Conventions.Member.IsApproved].Value == null)
+ return default(bool);
+
+ if (Properties[Constants.Conventions.Member.IsApproved].Value is bool)
+ return (bool)Properties[Constants.Conventions.Member.IsApproved].Value;
+
+ return (bool)Convert.ChangeType(Properties[Constants.Conventions.Member.IsApproved].Value, typeof(bool));
+ }
+ set
+ {
+ Properties[Constants.Conventions.Member.IsApproved].Value = value;
+ }
+ }
+
+ ///
+ /// Gets or sets a boolean indicating whether the Member is locked out
+ ///
+ ///
+ /// Alias: umbracoLockPropertyTypeAlias
+ /// Part of the standard properties collection.
+ ///
+ [IgnoreDataMember]
+ public bool IsLockedOut
+ {
+ get
+ {
+ if (Properties[Constants.Conventions.Member.IsLockedOut].Value == null)
+ return default(bool);
+
+ if (Properties[Constants.Conventions.Member.IsLockedOut].Value is bool)
+ return (bool)Properties[Constants.Conventions.Member.IsLockedOut].Value;
+
+ return (bool)Convert.ChangeType(Properties[Constants.Conventions.Member.IsLockedOut].Value, typeof(bool));
+ }
+ set
+ {
+ Properties[Constants.Conventions.Member.IsLockedOut].Value = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the date for last login
+ ///
+ ///
+ /// Alias: umbracoLastLoginPropertyTypeAlias
+ /// Part of the standard properties collection.
+ ///
+ [IgnoreDataMember]
+ public DateTime LastLoginDate
+ {
+ get
+ {
+ if (Properties[Constants.Conventions.Member.LastLoginDate].Value == null)
+ return default(DateTime);
+
+ if (Properties[Constants.Conventions.Member.LastLoginDate].Value is DateTime)
+ return (DateTime)Properties[Constants.Conventions.Member.LastLoginDate].Value;
+
+ return (DateTime)Convert.ChangeType(Properties[Constants.Conventions.Member.LastLoginDate].Value, typeof(DateTime));
+ }
+ set
+ {
+ Properties[Constants.Conventions.Member.LastLoginDate].Value = value;
+ }
+ }
+
+ ///
+ /// Gest or sets the date for last password change
+ ///
+ ///
+ /// Alias: umbracoMemberLastPasswordChange
+ /// Part of the standard properties collection.
+ ///
+ [IgnoreDataMember]
+ public DateTime LastPasswordChangeDate
+ {
+ get
+ {
+ if (Properties[Constants.Conventions.Member.LastPasswordChangeDate].Value == null)
+ return default(DateTime);
+
+ if (Properties[Constants.Conventions.Member.LastPasswordChangeDate].Value is DateTime)
+ return (DateTime)Properties[Constants.Conventions.Member.LastPasswordChangeDate].Value;
+
+ return (DateTime)Convert.ChangeType(Properties[Constants.Conventions.Member.LastPasswordChangeDate].Value, typeof(DateTime));
+ }
+ set
+ {
+ Properties[Constants.Conventions.Member.LastPasswordChangeDate].Value = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the date for when Member was locked out
+ ///
+ ///
+ /// Alias: umbracoMemberLastLockout
+ /// Part of the standard properties collection.
+ ///
+ [IgnoreDataMember]
+ public DateTime LastLockoutDate
+ {
+ get
+ {
+ if (Properties[Constants.Conventions.Member.LastLockoutDate].Value == null)
+ return default(DateTime);
+
+ if (Properties[Constants.Conventions.Member.LastLockoutDate].Value is DateTime)
+ return (DateTime)Properties[Constants.Conventions.Member.LastLockoutDate].Value;
+
+ return (DateTime)Convert.ChangeType(Properties[Constants.Conventions.Member.LastLockoutDate].Value, typeof(DateTime));
+ }
+ set
+ {
+ Properties[Constants.Conventions.Member.LastLockoutDate].Value = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the number of failed password attempts.
+ /// This is the number of times the password was entered incorrectly upon login.
+ ///
+ ///
+ /// Alias: umbracoFailedPasswordAttemptsPropertyTypeAlias
+ /// Part of the standard properties collection.
+ ///
+ [IgnoreDataMember]
+ public int FailedPasswordAttempts
+ {
+ get
+ {
+ if (Properties[Constants.Conventions.Member.FailedPasswordAttempts].Value == null)
+ return default(int);
+
+ if (Properties[Constants.Conventions.Member.FailedPasswordAttempts].Value is int)
+ return (int)Properties[Constants.Conventions.Member.FailedPasswordAttempts].Value;
+
+ return (int)Convert.ChangeType(Properties[Constants.Conventions.Member.FailedPasswordAttempts].Value, typeof(int));
+ }
+ set
+ {
+ Properties[Constants.Conventions.Member.LastLockoutDate].Value = value;
+ }
+ }
+
+ ///
+ /// String alias of the default ContentType
+ ///
+ [DataMember]
+ public virtual string ContentTypeAlias
+ {
+ get { return _contentTypeAlias; }
+ internal set
+ {
+ SetPropertyValueAndDetectChanges(o =>
+ {
+ _contentTypeAlias = value;
+ return _contentTypeAlias;
+ }, _contentTypeAlias, DefaultContentTypeAliasSelector);
+ }
+ }
+
+ ///
+ /// User key from the Provider.
+ ///
+ ///
+ /// When using standard umbraco provider this key will
+ /// correspond to the guid UniqueId/Key.
+ /// Otherwise it will the one available from the asp.net
+ /// membership provider.
+ ///
+ [DataMember]
+ internal virtual object ProviderUserKey
+ {
+ get
+ {
+ return _providerUserKey;
+ }
+ set
+ {
+ SetPropertyValueAndDetectChanges(o =>
+ {
+ _providerUserKey = value;
+ return _providerUserKey;
+ }, _providerUserKey, ProviderUserKeySelector);
+ }
+ }
+
+ ///
+ /// Gets or sets the type of the provider user key.
+ ///
+ ///
+ /// The type of the provider user key.
+ ///
+ [IgnoreDataMember]
+ internal Type ProviderUserKeyType
+ {
+ get
+ {
+ return _userTypeKey;
+ }
+ private set
+ {
+ SetPropertyValueAndDetectChanges(o =>
+ {
+ _userTypeKey = value;
+ return _userTypeKey;
+ }, _userTypeKey, UserTypeKeySelector);
+ }
+ }
+
+ ///
+ /// Sets the type of the provider user key.
+ ///
+ /// The type.
+ internal void SetProviderUserKeyType(Type type)
+ {
+ ProviderUserKeyType = type;
+ }
+
+ ///
+ /// Method to call when Entity is being saved
+ ///
+ /// Created date is set and a Unique key is assigned
+ internal override void AddingEntity()
+ {
+ base.AddingEntity();
+
+ if (Key == Guid.Empty)
+ Key = Guid.NewGuid();
+ }
+
+ ///
+ /// Gets the ContentType used by this content object
+ ///
+ [IgnoreDataMember]
+ public IMemberType ContentType
+ {
+ get { return _contentType; }
+ }
+
+ public override void ChangeTrashedState(bool isTrashed, int parentId = -20)
+ {
+ throw new NotImplementedException("Members can't be trashed as no Recycle Bin exists, so use of this method is invalid");
+ }
+
+ /* Internal experiment - only used for mapping queries.
+ * Adding these to have first level properties instead of the Properties collection.
+ */
+ internal string LongStringPropertyValue { get; set; }
+ internal string ShortStringPropertyValue { get; set; }
+ internal int IntegerropertyValue { get; set; }
+ internal bool BoolPropertyValue { get; set; }
+ internal DateTime DateTimePropertyValue { get; set; }
+ internal string PropertyTypeAlias { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Models/MemberType.cs b/src/Umbraco.Core/Models/MemberType.cs
new file mode 100644
index 0000000000..ed7d5cd3ab
--- /dev/null
+++ b/src/Umbraco.Core/Models/MemberType.cs
@@ -0,0 +1,118 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.Serialization;
+
+namespace Umbraco.Core.Models
+{
+ ///
+ /// Represents the content type that a object is based on
+ ///
+ [Serializable]
+ [DataContract(IsReference = true)]
+ public class MemberType : ContentTypeCompositionBase, IMemberType
+ {
+ //Dictionary is divided into string: PropertyTypeAlias, Tuple: MemberCanEdit, VisibleOnProfile, PropertyTypeId
+ private IDictionary> _memberTypePropertyTypes;
+
+ public MemberType(int parentId) : base(parentId)
+ {
+ _memberTypePropertyTypes = new Dictionary>();
+ }
+
+ public MemberType(IContentTypeComposition parent) : base(parent)
+ {
+ _memberTypePropertyTypes = new Dictionary>();
+ }
+
+ private static readonly PropertyInfo MemberTypePropertyTypesSelector = ExpressionHelper.GetPropertyInfo>>(x => x.MemberTypePropertyTypes);
+
+ ///
+ /// Gets or Sets a Dictionary of Tuples (MemberCanEdit, VisibleOnProfile, PropertyTypeId) by the PropertyTypes' alias.
+ ///
+ [DataMember]
+ internal IDictionary> MemberTypePropertyTypes
+ {
+ get { return _memberTypePropertyTypes; }
+ set
+ {
+ SetPropertyValueAndDetectChanges(o =>
+ {
+ _memberTypePropertyTypes = value;
+ return _memberTypePropertyTypes;
+ }, _memberTypePropertyTypes, MemberTypePropertyTypesSelector);
+ }
+ }
+
+ ///
+ /// Gets a boolean indicating whether a Property is editable by the Member.
+ ///
+ /// PropertyType Alias of the Property to check
+ ///
+ public bool MemberCanEditProperty(string propertyTypeAlias)
+ {
+ if (MemberTypePropertyTypes.ContainsKey(propertyTypeAlias))
+ {
+ return MemberTypePropertyTypes[propertyTypeAlias].Item1;
+ }
+
+ return false;
+ }
+
+ ///
+ /// Gets a boolean indicating whether a Property is visible on the Members profile.
+ ///
+ /// PropertyType Alias of the Property to check
+ ///
+ public bool MemberCanViewProperty(string propertyTypeAlias)
+ {
+ if (MemberTypePropertyTypes.ContainsKey(propertyTypeAlias))
+ {
+ return MemberTypePropertyTypes[propertyTypeAlias].Item2;
+ }
+
+ return false;
+ }
+
+ ///
+ /// Sets a boolean indicating whether a Property is editable by the Member.
+ ///
+ /// PropertyType Alias of the Property to set
+ /// Boolean value, true or false
+ public void SetMemberCanEditProperty(string propertyTypeAlias, bool value)
+ {
+ if (MemberTypePropertyTypes.ContainsKey(propertyTypeAlias))
+ {
+ var tuple = MemberTypePropertyTypes[propertyTypeAlias];
+ MemberTypePropertyTypes[propertyTypeAlias] = new Tuple(value, tuple.Item2, tuple.Item3);
+ }
+ else
+ {
+ var propertyType = PropertyTypes.First(x => x.Alias.Equals(propertyTypeAlias));
+ var tuple = new Tuple(value, false, propertyType.Id);
+ MemberTypePropertyTypes.Add(propertyTypeAlias, tuple);
+ }
+ }
+
+ ///
+ /// Sets a boolean indicating whether a Property is visible on the Members profile.
+ ///
+ /// PropertyType Alias of the Property to set
+ /// Boolean value, true or false
+ public void SetMemberCanViewProperty(string propertyTypeAlias, bool value)
+ {
+ if (MemberTypePropertyTypes.ContainsKey(propertyTypeAlias))
+ {
+ var tuple = MemberTypePropertyTypes[propertyTypeAlias];
+ MemberTypePropertyTypes[propertyTypeAlias] = new Tuple(tuple.Item1, value, tuple.Item3);
+ }
+ else
+ {
+ var propertyType = PropertyTypes.First(x => x.Alias.Equals(propertyTypeAlias));
+ var tuple = new Tuple(false, value, propertyType.Id);
+ MemberTypePropertyTypes.Add(propertyTypeAlias, tuple);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Models/Membership/IMembershipUser.cs b/src/Umbraco.Core/Models/Membership/IMembershipUser.cs
index b80faeee10..422b47da22 100644
--- a/src/Umbraco.Core/Models/Membership/IMembershipUser.cs
+++ b/src/Umbraco.Core/Models/Membership/IMembershipUser.cs
@@ -6,7 +6,7 @@ namespace Umbraco.Core.Models.Membership
{
internal interface IMembershipUser : IMembershipUserId, IAggregateRoot
{
- new object Id { get; set; }
+ /*new object Id { get; set; }*/
string Username { get; set; }
string Email { get; set; }
string Password { get; set; }
@@ -16,10 +16,6 @@ namespace Umbraco.Core.Models.Membership
bool IsApproved { get; set; }
bool IsOnline { get; set; }
bool IsLockedOut { get; set; }
- //Was CreationDate
- //DateTime CreateDate { get; set; }
- //LastActivityDate
- //DateTime UpdateDate { get; set; }
DateTime LastLoginDate { get; set; }
DateTime LastPasswordChangeDate { get; set; }
DateTime LastLockoutDate { get; set; }
diff --git a/src/Umbraco.Core/Models/Membership/Member.cs b/src/Umbraco.Core/Models/Membership/Member.cs
deleted file mode 100644
index 3fa26af085..0000000000
--- a/src/Umbraco.Core/Models/Membership/Member.cs
+++ /dev/null
@@ -1,159 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using System.Runtime.Serialization;
-
-namespace Umbraco.Core.Models.Membership
-{
- ///
- /// Represents an Umbraco Member
- ///
- ///
- /// Should be internal until a proper user/membership implementation
- /// is part of the roadmap.
- ///
- [Serializable]
- [DataContract(IsReference = true)]
- [DebuggerDisplay("Id: {Id}")]
- internal class Member : MemberProfile, IMembershipUser
- {
- private bool _hasIdentity;
- private int _id;
- private Guid _key;
- private DateTime _createDate;
- private DateTime _updateDate;
-
- private static readonly PropertyInfo IdSelector = ExpressionHelper.GetPropertyInfo(x => x.Id);
- private static readonly PropertyInfo KeySelector = ExpressionHelper.GetPropertyInfo(x => x.Key);
- private static readonly PropertyInfo CreateDateSelector = ExpressionHelper.GetPropertyInfo(x => x.CreateDate);
- private static readonly PropertyInfo UpdateDateSelector = ExpressionHelper.GetPropertyInfo(x => x.UpdateDate);
- private static readonly PropertyInfo HasIdentitySelector = ExpressionHelper.GetPropertyInfo(x => x.HasIdentity);
-
- ///
- /// Integer Id
- ///
- [DataMember]
- public new int Id
- {
- get
- {
- return _id;
- }
- set
- {
- SetPropertyValueAndDetectChanges(o =>
- {
- _id = value;
- HasIdentity = true; //set the has Identity
- return _id;
- }, _id, IdSelector);
- }
- }
-
- ///
- /// Guid based Id
- ///
- /// The key is currectly used to store the Unique Id from the
- /// umbracoNode table, which many of the entities are based on.
- [DataMember]
- public Guid Key
- {
- get
- {
- if (_key == Guid.Empty)
- return _id.ToGuid();
-
- return _key;
- }
- set
- {
- SetPropertyValueAndDetectChanges(o =>
- {
- _key = value;
- return _key;
- }, _key, KeySelector);
- }
- }
-
- ///
- /// Gets or sets the Created Date
- ///
- [DataMember]
- public DateTime CreateDate
- {
- get { return _createDate; }
- set
- {
- SetPropertyValueAndDetectChanges(o =>
- {
- _createDate = value;
- return _createDate;
- }, _createDate, CreateDateSelector);
- }
- }
-
- ///
- /// Gets or sets the Modified Date
- ///
- [DataMember]
- public DateTime UpdateDate
- {
- get { return _updateDate; }
- set
- {
- SetPropertyValueAndDetectChanges(o =>
- {
- _updateDate = value;
- return _updateDate;
- }, _updateDate, UpdateDateSelector);
- }
- }
-
- ///
- /// Indicates whether the current entity has an identity, eg. Id.
- ///
- public virtual bool HasIdentity
- {
- get
- {
- return _hasIdentity;
- }
- protected set
- {
- SetPropertyValueAndDetectChanges(o =>
- {
- _hasIdentity = value;
- return _hasIdentity;
- }, _hasIdentity, HasIdentitySelector);
- }
- }
-
- public string Username { get; set; }
- public string Email { get; set; }
-
- public string Password { get; set; }
- public string PasswordQuestion { get; set; }
- public string PasswordAnswer { get; set; }
- public string Comments { get; set; }
- public bool IsApproved { get; set; }
- public bool IsOnline { get; set; }
- public bool IsLockedOut { get; set; }
- public DateTime LastLoginDate { get; set; }
- public DateTime LastPasswordChangeDate { get; set; }
- public DateTime LastLockoutDate { get; set; }
-
- public object ProfileId { get; set; }
- public IEnumerable