public IHttpActionResult PostMostRecentLoggingEvent(MostRecentLoggingEvent mostRecentLoggingEvent) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.MostRecentLoggingEvents.Add(mostRecentLoggingEvent); try { db.SaveChanges(); } catch (DbUpdateException) { if (MostRecentLoggingEventExists(mostRecentLoggingEvent.ID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = mostRecentLoggingEvent.ID }, mostRecentLoggingEvent)); }
public IHttpActionResult PutMostRecentLoggingEvent(long id, MostRecentLoggingEvent mostRecentLoggingEvent) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != mostRecentLoggingEvent.ID) { return(BadRequest()); } db.Entry(mostRecentLoggingEvent).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MostRecentLoggingEventExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetMostRecentLoggingEvent(long id) { MostRecentLoggingEvent mostRecentLoggingEvent = db.MostRecentLoggingEvents.Find(id); if (mostRecentLoggingEvent == null) { return(NotFound()); } return(Ok(mostRecentLoggingEvent)); }
public IHttpActionResult DeleteMostRecentLoggingEvent(long id) { MostRecentLoggingEvent mostRecentLoggingEvent = db.MostRecentLoggingEvents.Find(id); if (mostRecentLoggingEvent == null) { return(NotFound()); } db.MostRecentLoggingEvents.Remove(mostRecentLoggingEvent); db.SaveChanges(); return(Ok(mostRecentLoggingEvent)); }