public IActionResult Delete(int id) { StoreDB.User user = _userService.Get(id); if (user == null) { return(NotFound("The User record couldn't be found.")); } _userService.Delete(user); return(NoContent()); }
public IActionResult Put(int id, [FromBody] StoreDB.User user) { if (user == null) { return(BadRequest("User is null.")); } StoreDB.User userToUpdate = _userService.Get(id); if (userToUpdate == null) { return(NotFound("The User record couldn't be found.")); } _userService.Update(userToUpdate, user); return(NoContent()); }
public IActionResult Post([FromBody] StoreDB.User value) { if (value == null) { return(BadRequest("user is null")); } try { _userService.Add(value); return(CreatedAtRoute("Get", new { Id = value.UserId }, value)); } catch (Exception ex) { return(BadRequest("user no saved => " + ex.Message)); } }