예제 #1
0
        public async Task <IActionResult> CreateBankWithAccount(int userId, BankForCreationDto bankForCreationDto)
        {
            bankForCreationDto.UserId = userId;
            var command = new CreateBankWithAccountCommand(bankForCreationDto);

            var result = await Mediator.Send(command);

            return(CreatedAtAction(nameof(GetBankById),
                                   new { bankId = result.Id, userId = bankForCreationDto.UserId }, result));
        }
예제 #2
0
        public async Task <ActionResult <BankDto> > Post([FromBody] BankForCreationDto bankForCreationDto)
        {
            if (await this._customerRepo.GetSingle(bankForCreationDto.CustomerId) == null)
            {
                return(BadRequest());
            }

            var bank = new Bank
            {
                AccountNumber     = bankForCreationDto.AccountNumber,
                AccountHolderName = bankForCreationDto.AccountHolderName,
                Sortcode          = bankForCreationDto.Sortcode,
                CustomerId        = bankForCreationDto.CustomerId
            };

            var bankForRep = await _bankRepo.Create(bank);

            var bankDto = _mapper.Map <BankDto>(bank);

            return(Ok(bankDto));
        }
 public CreateBankWithAccountCommand(BankForCreationDto bankForCreationDto)
 {
     BankForCreationDto = bankForCreationDto;
 }