public IHttpActionResult PutForhandler(int id, Forhandler forhandler) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != forhandler.ForhandlerID) { return(BadRequest()); } db.Entry(forhandler).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ForhandlerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetForhandler(int id) { Forhandler forhandler = db.Forhandlers.Find(id); if (forhandler == null) { return(NotFound()); } return(Ok(forhandler)); }
public IHttpActionResult PostForhandler(Forhandler forhandler) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Forhandlers.Add(forhandler); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = forhandler.ForhandlerID }, forhandler)); }
public IHttpActionResult DeleteForhandler(int id) { Forhandler forhandler = db.Forhandlers.Find(id); if (forhandler == null) { return(NotFound()); } db.Forhandlers.Remove(forhandler); db.SaveChanges(); return(Ok(forhandler)); }