Пример #1
0
        public async Task <RegisterResult> Process(RegisterCommand command)
        {
            Customer customer = new Customer(new PIN(command.PIN), new Name(command.Name));

            Account account = new Account();
            Credit  credit  = new Credit(new Amount(command.InitialAmount));

            account.Deposit(credit);

            customer.Register(account);

            await customerWriteOnlyRepository.Add(customer);

            CustomerResult customerResponse = resultConverter.Map <CustomerResult>(customer);
            AccountResult  accountResponse  = resultConverter.Map <AccountResult>(account);
            RegisterResult response         = new RegisterResult(customerResponse, accountResponse);

            return(response);
        }
Пример #2
0
        public async Task <RegisterResult> Process(RegisterCommand command)
        {
            Customer customer = new Customer(command.Personnummer, command.Name, command.Gender);

            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 <RegisterResult> Execute(string pin, string name, double initialAmount)
        {
            Customer customer = new Customer(pin, 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);

            RegisterResult result = new RegisterResult(customer, account);

            return(result);
        }
        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);
        }