public IHttpActionResult PutShopVisit(int id, ShopVisit shopVisit) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != shopVisit.Id) { return(BadRequest()); } db.Entry(shopVisit).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ShopVisitExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetShopVisit(int id) { ShopVisit shopVisit = db.ShopVisits.Find(id); if (shopVisit == null) { return(NotFound()); } return(Ok(shopVisit)); }
public IHttpActionResult PostShopVisit(ShopVisit shopVisit) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ShopVisits.Add(shopVisit); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = shopVisit.Id }, shopVisit)); }
public IHttpActionResult DeleteShopVisit(int id) { ShopVisit shopVisit = db.ShopVisits.Find(id); if (shopVisit == null) { return(NotFound()); } db.ShopVisits.Remove(shopVisit); db.SaveChanges(); return(Ok(shopVisit)); }