public IHttpActionResult PutItem(int id, Item item) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != item.Id_Item) { return(BadRequest()); } db.Entry(item).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ItemExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutBasket_Product(int id, Basket_Product basket_Product) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != basket_Product.Id_Basket) { return(BadRequest()); } db.Entry(basket_Product).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!Basket_ProductExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Contact(Contact contact) { if (ModelState.IsValid) { using (var ctx = new ShoppingStoreDB()) { ctx.Contacts.Add(contact); ctx.SaveChanges(); } } return(View(contact)); }
public ActionResult AddCategory(Category category) { if (ModelState.IsValid) { using (var ctx = new ShoppingStoreDB()) { ctx.Categories.Add(category); ctx.SaveChanges(); } } //return View(category); return(RedirectToAction("Categories")); }
public ActionResult Delete(int id) { using (var ctx = new ShoppingStoreDB()) { var product = ctx.Products.Find(id); if (product != null) { ctx.Products.Remove(product); ctx.SaveChanges(); } } return(RedirectToAction("ProductsGrid")); }
public ActionResult Delete(int id) { using (var categ = new ShoppingStoreDB()) { var category = categ.Categories.Find(id); if (category != null) { categ.Categories.Remove(category); categ.SaveChanges(); } } return(RedirectToAction("Categories")); }
public ActionResult Delete(int id) { using (var ctx = new ShoppingStoreDB()) { var contact = ctx.Contacts.Find(id); if (contact != null) { ctx.Contacts.Remove(contact); ctx.SaveChanges(); } } return(RedirectToAction("Index")); }
public ActionResult Edit(Category category) { if (ModelState.IsValid) { using (var ctx = new ShoppingStoreDB()) { if (category.Id_Category > 0) { ctx.UpdateCategory(category); } else { ctx.Categories.Add(category); ctx.SaveChanges(); } } } return(RedirectToAction("Categories")); }