public IHttpActionResult PutIncident_Level(int id, Incident_Level incident_Level) { db.Configuration.ProxyCreationEnabled = false; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != incident_Level.Incident_Level_ID) { return(BadRequest()); } db.Entry(incident_Level).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!Incident_LevelExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostIncident_Level(Incident_Level incident_Level) { db.Configuration.ProxyCreationEnabled = false; try { string response = ""; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (db.Incident_Level.Count(e => e.Description == incident_Level.Description) > 0) { response = "exists"; return(BadRequest(response)); } else { db.Incident_Level.Add(incident_Level); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = incident_Level.Incident_Level_ID }, incident_Level)); } } catch (Exception err) { return(BadRequest(err.ToString())); } }
public IHttpActionResult GetIncident_Level(int id) { db.Configuration.ProxyCreationEnabled = false; Incident_Level incident_Level = db.Incident_Level.Find(id); if (incident_Level == null) { return(NotFound()); } return(Ok(incident_Level)); }
public IHttpActionResult DeleteIncident_Level(int id) { db.Configuration.ProxyCreationEnabled = false; Incident_Level incident_Level = db.Incident_Level.Find(id); if (incident_Level == null) { return(NotFound()); } db.Incident_Level.Remove(incident_Level); db.SaveChanges(); return(Ok(incident_Level)); }