private EmailAccount(CreateEmailAccount cmd) : base(cmd.Id) { SiteId = cmd.SiteId; Address = cmd.Address; DisplayName = cmd.DisplayName; Host = cmd.Host; Port = cmd.Port; UserName = cmd.UserName; Password = cmd.Password; DefaultCredentials = cmd.DefaultCredentials; Ssl = cmd.Ssl; Status = EmailAccountStatus.Active; AddEvent(new EmailAccountCreated { SiteId = SiteId, AggregateRootId = Id, Address = Address, DisplayName = DisplayName, Host = Host, Port = Port, UserName = UserName, Password = Password, DefaultCredentials = DefaultCredentials, Ssl = Ssl, Status = Status }); }
private void Apply(EmailAccountCreated @event) { Id = @event.AggregateRootId; SiteId = @event.SiteId; Address = @event.Address; DisplayName = @event.DisplayName; Host = @event.Host; Port = @event.Port; UserName = @event.UserName; Password = @event.Password; DefaultCredentials = @event.DefaultCredentials; Ssl = @event.Ssl; Status = EmailAccountStatus.Active; }
public void Delete(DeleteEmailAccount cmd, IValidator <DeleteEmailAccount> validator) { validator.ValidateCommand(cmd); if (Status == EmailAccountStatus.Deleted) { throw new Exception("Email account already deleted."); } Status = EmailAccountStatus.Deleted; AddEvent(new EmailAccountDeleted { SiteId = SiteId, AggregateRootId = Id }); }
private void Apply(EmailAccountDeleted @event) { Status = EmailAccountStatus.Deleted; }