public IHttpActionResult PostSystem(StatusPage.Data.Models.System system) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Systems.Add(system); try { db.SaveChanges(); } catch (DbUpdateException) { if (SystemExists(system.ID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = system.ID }, system)); }
public IHttpActionResult PutSystem(Guid id, StatusPage.Data.Models.System system) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != system.ID) { return(BadRequest()); } db.Entry(system).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SystemExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetSystem(Guid id) { StatusPage.Data.Models.System system = db.Systems.Find(id); if (system == null) { return(NotFound()); } return(Ok(system)); }
public IHttpActionResult DeleteSystem(Guid id) { StatusPage.Data.Models.System system = db.Systems.Find(id); if (system == null) { return(NotFound()); } db.Systems.Remove(system); db.SaveChanges(); return(Ok(system)); }