public IHttpActionResult Putviolationcode(int id, violationcode violationcode) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != violationcode.ID) { return(BadRequest()); } db.Entry(violationcode).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!violationcodeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult Getviolationcode(int id) { violationcode violationcode = db.violationcodes.Find(id); if (violationcode == null) { return(NotFound()); } return(Ok(violationcode)); }
public IHttpActionResult Postviolationcode(violationcode violationcode) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.violationcodes.Add(violationcode); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = violationcode.ID }, violationcode)); }
public IHttpActionResult Deleteviolationcode(int id) { violationcode violationcode = db.violationcodes.Find(id); if (violationcode == null) { return(NotFound()); } db.violationcodes.Remove(violationcode); db.SaveChanges(); return(Ok(violationcode)); }