Пример #1
0
        public async Task <UserResponseDomainModel> Post(UserCreateDomainModel user)
        {
            var entity = _mapper.Map <UserEntity>(user);
            var result = await _repository.InsertAsync(entity);

            return(_mapper.Map <UserResponseDomainModel>(result));
        }
Пример #2
0
        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));
            }
        }