示例#1
0
        public void Handle(OpenedDomainEvent domainEvent)
        {
            Account account = new Account();

            account.Apply(domainEvent);
            accountWriteOnlyRepository.Add(domainEvent).Wait();
        }
        public void Handle(RegisteredDomainEvent domainEvent)
        {
            Customer customer = Customer.Create();

            customer.Apply(domainEvent);
            customerWriteOnlyRepository.Add(customer).Wait();

            Account account = Account.Create(domainEvent.AggregateRootId);

            account.Apply(domainEvent);
            accountWriteOnlyRepository.Add(account).Wait();
        }
        public async Task <CreateAccountOutput> Run(string accountName)
        {
            if (string.IsNullOrEmpty(accountName))
            {
                throw new ApplicationException("Account must have a name.");
            }

            var newAccount = new Account(accountName);

            await _accountWriteOnlyRepository.Add(newAccount);

            return(new CreateAccountOutput(newAccount.Id, newAccount.Name, newAccount.Balance));
        }
示例#4
0
        public async Task<RegisterOutput> 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);

            RegisterOutput output = new RegisterOutput(customer, account);
            return output;
        }
示例#5
0
        public async Task <RegisterResult> Execute(RegisterCommand command)
        {
            Customer customer = new Customer(command.Pin, 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 <RegisterOutput> Execute(Personnummer 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);
        }
        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);
        }
示例#8
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);
        }
示例#9
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);
        }