public IHttpActionResult PutProduct(int id, Product product) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != product.ID) { return(BadRequest()); } db.Entry(product).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void UpdateCategory(Category category) { using (var context = new EAContext()) { context.Entry(category).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void UpdateProduct(Product product) { using (var context = new EAContext()) { context.Entry(product).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void UpdateFoodandMedicine(FoodandMedicine foodandMedicine) { using (var context = new EAContext()) { context.Entry(foodandMedicine).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void CreateReview(Review review) { using (var context = new EAContext()) { context.Entry(review.Product).State = EntityState.Unchanged; context.Reviews.Add(review); context.SaveChanges(); } }
public void CreateProduct(Product product) { using (var context = new EAContext()) { context.Entry(product.Category).State = EntityState.Unchanged; context.Products.Add(product); context.SaveChanges(); } }
public void CreateFoodandMedicine(FoodandMedicine foodandMedicine) { using (var context = new EAContext()) { context.Entry(foodandMedicine.Category).State = EntityState.Unchanged; context.FoodandMedicines.Add(foodandMedicine); context.SaveChanges(); } }
public bool UpdateOrderStatus(int ID, string status) { using (var context = new EAContext()) { var order = context.Orders.Find(ID); order.Status = status; context.Entry(order).State = EntityState.Modified; return(context.SaveChanges() > 0); } }