예제 #1
0
        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));
        }
예제 #2
0
        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));
        }