public RegisteredCustomer(AccountName accountName, string name, string email, DateTime createdAt)
 {
     AccountName = accountName;
     Name        = name;
     Email       = email;
     CreatedAt   = createdAt;
 }
 public CustomerRegistered(DateTime createdAt, AccountName accountName, string name, string email,
                           string password)
 {
     CreatedAt   = createdAt;
     AccountName = accountName;
     Name        = name;
     Email       = email;
     Password    = password;
     PId         = System.Diagnostics.Process.GetCurrentProcess().Id;
 }
        public void Call(RegisterCustomerAccountCommand c)
        {
            var accountName = new AccountName(c.AccountName);
            var customer    = _customerLoader(accountName);

            if (customer != Customer.None)
            {
                throw new CannotRegisterCustomerAlreadyExistsException(c);
            }

            Customer.RegisterAccount(accountName, c.Name, new Email(c.Email), c.Password, _passwordHasher, _dateTimeSource(), _eventWriter);
        }
Exemplo n.º 4
0
        private static Customer Load(AccountName accountName, Func <AccountName, IEnumerable <IEvent> > eventSource, IPaymentMethodFactory paymentMethodFactory)
        {
            IEnumerable <dynamic> events = eventSource(accountName);


            if (!events.Any())
            {
                return(None);
            }

            var customer = new Customer(RegisteredCustomer.None, paymentMethodFactory);

            return(events.Aggregate(customer, (c, e) => c.Apply(e)));
        }
Exemplo n.º 5
0
 public static void RegisterAccount(AccountName accountName, string customerName, Email email,
                                    string password, Func <string, string> passwordHasher, DateTime now, Action <AccountName, IEvent> eventWriter)
 {
     eventWriter(accountName,
                 new CustomerRegistered(now, accountName, customerName, email.Value, passwordHasher(password)));
 }
Exemplo n.º 6
0
 public static string CustomerStream(AccountName accountName)
 {
     return($"customer-{accountName.Value}");
 }