public async Task <UserResponseDomainModel> Post(UserCreateDomainModel user) { var entity = _mapper.Map <UserEntity>(user); var result = await _repository.InsertAsync(entity); return(_mapper.Map <UserResponseDomainModel>(result)); }
public async Task <ActionResult> Post([FromBody] UserCreateDomainModel user) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var result = await _service.Post(user); if (result != null) { return(Created(new Uri(Url.Link("GetWithId", new { id = result.Id })), result)); } else { return(BadRequest()); } } catch (ArgumentException e) { return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message)); } }