Ejemplo n.º 1
0
        public async Task <RegisterOutput> Execute(SSN personnummer, Name name, Amount initialAmount)
        {
            Customer customer = new Customer(personnummer, name);

            Account account = new Account(customer.Id);

            account.Deposit(initialAmount);
            Credit credit = (Credit)account.GetLastTransaction();

            customer.Register(account.Id);

            await _customerWriteOnlyRepository.Add(customer);

            await _accountWriteOnlyRepository.Add(account, credit);

            RegisterOutput output = new RegisterOutput(customer, account);

            return(output);
        }
Ejemplo n.º 2
0
        public async Task <RegisterResult> Process(RegisterCommand command)
        {
            Customer customer = new Customer(command.Personnummer, command.Name);

            Account account = new Account(customer.Id);

            account.Deposit(command.InitialAmount);
            Credit credit = (Credit)account.GetLastTransaction();

            customer.Register(account.Id);

            await customerWriteOnlyRepository.Add(customer);

            await accountWriteOnlyRepository.Add(account, credit);

            RegisterResult result = new RegisterResult(customer, account);

            return(result);
        }
        public async Task <Customer> Handle(RegisterCustomerCommand command)
        {
            Customer customer = Customer.Create(
                PIN.Create(command.PIN),
                Name.Create(command.Name));

            Amount amount = Amount.Create(command.InitialAmount);

            Account account = Account.Create(
                customer,
                amount);

            customer.Register(account);

            await customerWriteOnlyRepository.Add(customer);

            await accountWriteOnlyRepository.Add(account);

            return(customer);
        }
Ejemplo n.º 4
0
        public async Task <Customer> Handle(RegisterMessage command)
        {
            Customer customer = Customer.Create(
                PIN.Create(command.PIN),
                Name.Create(command.Name));

            Account account = Account.Create(customer);

            customer.Register(account);

            await customerWriteOnlyRepository.Add(customer);

            Credit credit = Credit.Create(Amount.Create(command.InitialAmount));

            account.Deposit(credit);

            await accountWriteOnlyRepository.Add(account);

            return(customer);
        }
Ejemplo n.º 5
0
        public async Task Process(RegisterInput input)
        {
            Customer customer = new Customer(input.PIN, input.Name);

            Account account = new Account(customer.Id);
            Credit  credit  = new Credit(account.Id, input.InitialAmount);

            account.Deposit(credit);

            customer.Register(account.Id);

            await customerWriteOnlyRepository.Add(customer);

            await accountWriteOnlyRepository.Add(account, credit);

            CustomerOutput customerOutput = outputConverter.Map <CustomerOutput>(customer);
            AccountOutput  accountOutput  = outputConverter.Map <AccountOutput>(account);
            RegisterOutput output         = new RegisterOutput(customerOutput, accountOutput);

            outputBoundary.Populate(output);
        }
        public async Task <RegisterResult> Process(RegisterCommand command)
        {
            Customer customer = new Customer(command.PIN, command.Name);

            Account account = new Account(customer.Id);
            Credit  credit  = new Credit(account.Id, command.InitialAmount);

            account.Deposit(credit);

            customer.Register(account.Id);

            await customerWriteOnlyRepository.Add(customer);

            await accountWriteOnlyRepository.Add(account, credit);

            CustomerResult customerResult = resultConverter.Map <CustomerResult>(customer);
            AccountResult  accountResult  = resultConverter.Map <AccountResult>(account);
            RegisterResult result         = new RegisterResult(customerResult, accountResult);

            return(result);
        }
 public int Execute(Domain.Entities.Customer.Customer customer)
 {
     return(customerWriteOnlyRepository.Add(customer));
 }
Ejemplo n.º 8
0
 public void Handle(RegisteredDomainEvent domainEvent)
 {
     customerWriteOnlyRepository.Add(domainEvent).Wait();
 }