Interface IMembershipMemberService<T>
Defines part of the UserService/MemberService, which is specific to methods used by the membership provider. The generic type is restricted to IMembershipUser. The implementation of this interface uses either IMember for the MemberService or IUser for the UserService.
Namespace: Umbraco.Core.Services
Assembly: Umbraco.Core.dll
Syntax
public interface IMembershipMemberService<T> : IService where T : class, IMembershipUser
Type Parameters
Name | Description |
---|---|
T |
Remarks
Idea is to have this as an isolated interface so that it can be easily 'replaced' in the membership provider implementation.
Methods
View SourceCreateWithIdentity(String, String, String, String)
Creates and persists a new IMembershipUser
Declaration
T CreateWithIdentity(string username, string email, string passwordValue, string memberTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
System.String | username | Username of the IMembershipUser to create |
System.String | Email of the IMembershipUser to create |
|
System.String | passwordValue | This value should be the encoded/encrypted/hashed value for the password that will be stored in the database |
System.String | memberTypeAlias | Alias of the Type |
Returns
Type | Description |
---|---|
T | IMembershipUser |
Remarks
An IMembershipUser can be of type IMember or IUser
CreateWithIdentity(String, String, String, String, Boolean)
Creates and persists a new IMembershipUser
Declaration
T CreateWithIdentity(string username, string email, string passwordValue, string memberTypeAlias, bool isApproved)
Parameters
Type | Name | Description |
---|---|---|
System.String | username | Username of the IMembershipUser to create |
System.String | Email of the IMembershipUser to create |
|
System.String | passwordValue | This value should be the encoded/encrypted/hashed value for the password that will be stored in the database |
System.String | memberTypeAlias | Alias of the Type |
System.Boolean | isApproved | IsApproved of the IMembershipUser to create |
Returns
Type | Description |
---|---|
T | IMembershipUser |
Remarks
An IMembershipUser can be of type IMember or IUser
Delete(T)
Deletes an IMembershipUser
Declaration
void Delete(T membershipUser)
Parameters
Type | Name | Description |
---|---|---|
T | membershipUser |
Remarks
An IMembershipUser can be of type IMember or IUser
Exists(String)
Checks if a Member with the username exists
Declaration
bool Exists(string username)
Parameters
Type | Name | Description |
---|---|---|
System.String | username | Username to check |
Returns
Type | Description |
---|---|
System.Boolean |
|
FindByEmail(String, Int64, Int32, out Int64, StringPropertyMatchType)
Finds a list of IMembershipUser objects by a partial email string
Declaration
IEnumerable<T> FindByEmail(string emailStringToMatch, long pageIndex, int pageSize, out long totalRecords, StringPropertyMatchType matchType = StringPropertyMatchType.StartsWith)
Parameters
Type | Name | Description |
---|---|---|
System.String | emailStringToMatch | Partial email string to match |
System.Int64 | pageIndex | Current page index |
System.Int32 | pageSize | Size of the page |
System.Int64 | totalRecords | Total number of records found (out) |
StringPropertyMatchType | matchType | The type of match to make as StringPropertyMatchType. Default is StartsWith |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> | System.Collections.Generic.IEnumerable<T> |
Remarks
An IMembershipUser can be of type IMember or IUser
FindByUsername(String, Int64, Int32, out Int64, StringPropertyMatchType)
Finds a list of IMembershipUser objects by a partial username
Declaration
IEnumerable<T> FindByUsername(string login, long pageIndex, int pageSize, out long totalRecords, StringPropertyMatchType matchType = StringPropertyMatchType.StartsWith)
Parameters
Type | Name | Description |
---|---|---|
System.String | login | Partial username to match |
System.Int64 | pageIndex | Current page index |
System.Int32 | pageSize | Size of the page |
System.Int64 | totalRecords | Total number of records found (out) |
StringPropertyMatchType | matchType | The type of match to make as StringPropertyMatchType. Default is StartsWith |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> | System.Collections.Generic.IEnumerable<T> |
Remarks
An IMembershipUser can be of type IMember or IUser
GetAll(Int64, Int32, out Int64)
Gets a list of paged IMembershipUser objects
Declaration
IEnumerable<T> GetAll(long pageIndex, int pageSize, out long totalRecords)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | pageIndex | Current page index |
System.Int32 | pageSize | Size of the page |
System.Int64 | totalRecords | Total number of records found (out) |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> | System.Collections.Generic.IEnumerable<T> |
Remarks
An IMembershipUser can be of type IMember or IUser
GetByEmail(String)
Get an IMembershipUser by email
Declaration
T GetByEmail(string email)
Parameters
Type | Name | Description |
---|---|---|
System.String | Email to use for retrieval |
Returns
Type | Description |
---|---|
T | IMembershipUser |
Remarks
An IMembershipUser can be of type IMember or IUser
GetByProviderKey(Object)
Gets an IMembershipUser by its provider key
Declaration
T GetByProviderKey(object id)
Parameters
Type | Name | Description |
---|---|---|
System.Object | id | Id to use for retrieval |
Returns
Type | Description |
---|---|
T | IMembershipUser |
Remarks
An IMembershipUser can be of type IMember or IUser
GetByUsername(String)
Get an IMembershipUser by username
Declaration
T GetByUsername(string username)
Parameters
Type | Name | Description |
---|---|---|
System.String | username | Username to use for retrieval |
Returns
Type | Description |
---|---|
T | IMembershipUser |
Remarks
An IMembershipUser can be of type IMember or IUser
GetCount(MemberCountType)
Gets the total number of Members or Users based on the count type
Declaration
int GetCount(MemberCountType countType)
Parameters
Type | Name | Description |
---|---|---|
MemberCountType | countType | MemberCountType to count by |
Returns
Type | Description |
---|---|
System.Int32 |
Remarks
The way the Online count is done is the same way that it is done in the MS SqlMembershipProvider - We query for any members that have their last active date within the Membership.UserIsOnlineTimeWindow (which is in minutes). It isn't exact science but that is how MS have made theirs so we'll follow that principal.
GetDefaultMemberType()
Gets the default MemberType alias
Declaration
string GetDefaultMemberType()
Returns
Type | Description |
---|---|
System.String | Alias of the default MemberType |
Remarks
By default we'll return the 'writer', but we need to check it exists. If it doesn't we'll return the first type that is not an admin, otherwise if there's only one we will return that one.
Save(T, Boolean)
Saves an IMembershipUser
Declaration
void Save(T entity, bool raiseEvents = true)
Parameters
Type | Name | Description |
---|---|---|
T | entity | |
System.Boolean | raiseEvents | Optional parameter to raise events.
Default is |
Remarks
An IMembershipUser can be of type IMember or IUser
Save(IEnumerable<T>, Boolean)
Saves a list of IMembershipUser objects
Declaration
void Save(IEnumerable<T> entities, bool raiseEvents = true)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | entities | System.Collections.Generic.IEnumerable<T> to save |
System.Boolean | raiseEvents | Optional parameter to raise events.
Default is |
Remarks
An IMembershipUser can be of type IMember or IUser
SetLastLogin(String, DateTime)
Sets the last login date for the member if they are found by username
Declaration
void SetLastLogin(string username, DateTime date)
Parameters
Type | Name | Description |
---|---|---|
System.String | username | |
System.DateTime | date |
Remarks
This is a specialized method because whenever a member logs in, the membership provider requires us to set the 'online' which requires updating their login date. This operation must be fast and cannot use database locks which is fine if we are only executing a single query for this data since there won't be any other data contention issues.