//[ProducesResponseType(201)] //[ProducesResponseType(400)] public IActionResult Post([FromBody] UserViewModel model) { try { if (ModelState.IsValid) { var newUser = _mapper.Map <UserViewModel, User>(model); _repository.AddEntity(newUser); if (_repository.SaveAll()) { return(Created($"/api/orders/{newUser.Id}", _mapper.Map <User, UserViewModel>(newUser))); } else { return(BadRequest("Failed to save user")); } } else { return(BadRequest(ModelState)); } } catch (Exception ex) { _logger.LogError(ex.Message); return(BadRequest("Failed to save users")); } }