public async Task <IHttpActionResult> Post(User user) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Users.Add(user); await db.SaveChangesAsync(); return(Ok(UsersViewModel.MapFrom(user))); }
public async Task <IHttpActionResult> Delete(long id) { User user = await db.Users.FindAsync(id); if (user == null) { return(NotFound()); } else { db.Users.Remove(user); await db.SaveChangesAsync(); return(Ok(UsersViewModel.MapFrom(user))); } }