public IHttpActionResult PutGunUser(int id, GunUser gunUser) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != gunUser.GunUserID) { return(BadRequest()); } db.Entry(gunUser).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!GunUserExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetGunUser(int id) { GunUser gunUser = db.GunUsers.Find(id); if (gunUser == null) { return(NotFound()); } return(Ok(gunUser)); }
public IHttpActionResult PostGunUser(GunUser gunUser) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.GunUsers.Add(gunUser); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = gunUser.GunUserID }, gunUser)); }
public IHttpActionResult DeleteGunUser(int id) { GunUser gunUser = db.GunUsers.Find(id); if (gunUser == null) { return(NotFound()); } db.GunUsers.Remove(gunUser); db.SaveChanges(); return(Ok(gunUser)); }