public IHttpActionResult PostVadi(Vadi vadi) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Vadis.Add(vadi); try { db.SaveChanges(); } catch (DbUpdateException) { if (VadiExists(vadi.Vadi_ID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("BatmanApi-VadisController", new { id = vadi.Vadi_ID }, vadi)); }
public IHttpActionResult PutVadi(int id, Vadi vadi) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != vadi.Vadi_ID) { return(BadRequest()); } db.Entry(vadi).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!VadiExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetVadi(int id) { Vadi vadi = db.Vadis.Find(id); if (vadi == null) { return(NotFound()); } return(Ok(vadi)); }
public IHttpActionResult DeleteVadi(int id) { Vadi vadi = db.Vadis.Find(id); if (vadi == null) { return(NotFound()); } db.Vadis.Remove(vadi); db.SaveChanges(); return(Ok(vadi)); }