public IHttpActionResult PostKabinets(Kabineti kabinets) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Kabinets.Add(kabinets); try { db.SaveChanges(); } catch (DbUpdateException) { if (KabinetsExists(kabinets.Elektronika)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("WolverineApi-Kabinets", new { id = kabinets.Elektronika }, kabinets)); }
public IHttpActionResult PutKabinets(string id, Kabineti kabinets) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != kabinets.Elektronika) { return(BadRequest()); } db.Entry(kabinets).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!KabinetsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetKabinets(string id) { Kabineti kabinets = db.Kabinets.Find(id); if (kabinets == null) { return(NotFound()); } return(Ok(kabinets)); }
public IHttpActionResult DeleteKabinets(string id) { Kabineti kabinets = db.Kabinets.Find(id); if (kabinets == null) { return(NotFound()); } db.Kabinets.Remove(kabinets); db.SaveChanges(); return(Ok(kabinets)); }