示例#1
0
        public async Task <IActionResult> GetAsync()
        {
            var accounts = await this.getAccountsUseCase.GetAsync();

            var dtoAccounts =
                accounts
                .Select(a => AccountDto.FromDomain(a))
                .ToList();

            return(Ok(dtoAccounts));
        }
示例#2
0
        public async Task <IActionResult> GetAsync([FromRoute] int id)
        {
            try
            {
                var account = await this.getAccountsUseCase.GetAsync(new AccountId(id));

                var dtoAccount = AccountDto.FromDomain(account);

                return(Ok(dtoAccount));
            }
            catch (NotFoundException <AccountId> )
            {
                return(NotFound());
            }
        }
示例#3
0
        public async Task QuandOnVeutCreerLeCompte()
        {
            this.repository = Substitute.For <IAccountRepository>();
            this.repository.GetAsync(Arg.Any <AccountId>()).Returns(this.existingAccountFromId);

            this.repository.IdExists(Arg.Any <AccountId>()).Returns((existingAccountFromId != null));

            this.repository.NameExists(Arg.Any <AccountName>()).Returns((existingAccountFromName != null));

            var createUseCase = new CreateAccountUseCase(repository);

            var accountController = new AccountController(Substitute.For <IGetAccountsUseCase>(), Substitute.For <IArchiveAccountUseCase>(), createUseCase);
            var accountToCreate   = AccountDto.FromDomain(this.futureAccount);

            this.result = await accountController.CreateAsync(accountToCreate);
        }