public ActionResult <AccountReadDto> CreateAccount(AccountCreateDto accountCreateDto) { var accountModel = _mapper.Map <Account>(accountCreateDto); try { _repository.CreateAccount(accountModel); } catch (ArgumentException e) { return(BadRequest(e.Message)); } _repository.SaveChanges(); var accountReadDto = _mapper.Map <AccountReadDto>(accountModel); return(CreatedAtRoute(nameof(GetAccount), new { Id = accountReadDto.Id }, accountReadDto)); }
public ActionResult <UserReadDto> CreateUser(UserCreateDto userCreateDto) { var userModel = _mapper.Map <User>(userCreateDto); try { _repository.CreateUser(userModel); } catch (ArgumentException e) { return(BadRequest(e.Message)); } _repository.SaveChanges(); var userReadDto = _mapper.Map <UserReadDto>(userModel); return(CreatedAtRoute(nameof(GetUser), new { Id = userReadDto.Id }, userReadDto)); }