Guides

CustomerService

Describes the CustomerService

These routines provide a way to generate new customer records. In Merchello, we have two types of customers. Anonymous customers are everyday shoppers who have not authenticated the site and use the AnonymousCustomer class. Authenticated shoppers (members in the Umbraco world) use the Customer class.

Instantiating

The CustomerService is exposed through the MerchelloContext

var customerService = MerchelloContext.Current.Services.CustomerService;

Class

public class CustomerService : PageCachedServiceBase<ICustomer>, 
    ICustomerService, IPageCachedService<ICustomer>, IService, IStaticCollectionService<ICustomer>

Constructors

NameDescription
CustomerService()Initializes a new instance of the CustomerService class.
CustomerService(ILogger)Initializes a new instance of the CustomerService class.
CustomerService(RepositoryFactory, ILogger, IAnonymousCustomerService, ICustomerAddressService, IInvoiceService, IPaymentService)Initializes a new instance of the CustomerService class.
CustomerService(IDatabaseUnitOfWorkProvider, RepositoryFactory, ILogger, IAnonymousCustomerService, ICustomerAddressService, IInvoiceService, IPaymentService)Initializes a new instance of the CustomerService class.
CustomerService(IDatabaseUnitOfWorkProvider, RepositoryFactory, ILogger, IEventMessagesFactory, IAnonymousCustomerService, ICustomerAddressService, IInvoiceService, IPaymentService)Initializes a new instance of the CustomerService class.

Public Methods

NameDescription
AddToCollection(Guid, Guid)Add a customer to a collection.
AddToCollection(ICustomer, IEntityCollection)Add a customer to a collection.
AddToCollection(ICustomer, Guid)Add a customer to a collection.
CreateAnonymousCustomerWithKeyCreates an IAnonymousCustomer and saves it to the database
CreateCustomerCreates a customer without saving to the database
CreateCustomerWithKey(String)Creates a customer with the Umbraco login name
CreateCustomerWithKey(String, String, String, String)Creates a customer and saves the record to the database
CustomerCountGets the total customer count.
Delete(IAnonymousCustomer)Deletes a single IAnonymousCustomer
Delete(IEnumerable(IAnonymousCustomer))Deletes a collection of IAnonymousCustomer objects
Delete(ICustomerAddress)Delete(ICustomerAddress)
Delete(ICustomerAddress)Deletes a single ICustomer
Delete(IEnumerable(ICustomer), Boolean)Deletes a collection ICustomer
ExistsInCollectionDetermines if an customer exists in a collection.
GetAddressByKeyGets an address by it's key
GetAnyByKeyGets an ICustomer or IAnonymousCustomer by its 'UniqueId'
GetByCustomerKey(Guid)Gets a collection of ICustomerAddress by the customer ke
GetByCustomerKey(Guid, AddressType)Gets a collection of ICustomerAddress by the customer key filtered by an AddressType
GetByKeyGets a customer by its unique id
GetByKeysGets a list of customer give a list of unique keys
GetByLoginNameGets a list of customer give a list of unique keys
GetDefaultCustomerAddressGets the default customer address of a certain type
GetFromCollection(Guid, Int64, Int64, String, SortDirection)Gets a page of customers from a collection.
GetFromCollection(Guid, String, Int64, Int64, String, SortDirection)Gets a page of customers from a collection with a search term.
GetPageGets a page of customers.
RemoveFromCollection(Guid, Guid)Removes a customer from a collection
RemoveFromCollection(ICustomer, IEntityCollection)Removes a customer from a collection
RemoveFromCollection(ICustomer, Guid)Removes a customer from a collection
Save(ICustomerAddress)Saves a single ICustomerAddress
Save(IEnumerable(ICustomerAddress))Saves a collection ICustomerAddress
Save(IAnonymousCustomer, Boolean)Saves a single IAnonymousCustomer
Save(ICustomer, Boolean)Saves a single ICustomer
Save(IEnumerable(ICustomer), Boolean)Saves a collection of ICustomer

Events

NameDescription
CreatingOccurs before create
CreatedOccurs after create
DeletingOccurs before delete
DeletedOccurs after delete
SavingOccurs before saving
SavedOccurs after saved

Interface on GitHub

https://github.com/Merchello/Merchello/blob/master/src/Merchello.Core/Services/Interfaces/ICustomerService.cs