public ActionResult DeleteConfirmed(int id) { CustomerProdcut customerProdcut = db.CustomerProdcut.Find(id); db.CustomerProdcut.Remove(customerProdcut); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,CustomerId,ProdcutId")] CustomerProdcut customerProdcut) { if (ModelState.IsValid) { db.Entry(customerProdcut).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerId = new SelectList(db.Customers, "Id", "Name", customerProdcut.CustomerId); ViewBag.ProdcutId = new SelectList(db.CategoryProduct, "Id", "Name", customerProdcut.CategoryProductId); return(View(customerProdcut)); }
// GET: CustomerProdcuts/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CustomerProdcut customerProdcut = db.CustomerProdcut.Find(id); if (customerProdcut == null) { return(HttpNotFound()); } return(View(customerProdcut)); }
// GET: CustomerProdcuts/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CustomerProdcut customerProdcut = db.CustomerProdcut.Find(id); if (customerProdcut == null) { return(HttpNotFound()); } ViewBag.CustomerId = new SelectList(db.Customers, "Id", "Name", customerProdcut.CustomerId); ViewBag.ProdcutId = new SelectList(db.CategoryProduct, "Id", "Name", customerProdcut.CategoryProductId); return(View(customerProdcut)); }
public ActionResult Create(CustomerProdcut CustomerProductToBeAdded) { if (ModelState.IsValid) { var CustProdDb = db.CategoryProduct.Where(a => a.Id == CustomerProductToBeAdded.CategoryProductId).FirstOrDefault(); if (CustProdDb.NumberInStock == 0) { return(Json("Stock Not Found That Product")); } CustProdDb.NumberInStock = CustProdDb.NumberInStock - 1; db.CategoryProduct.AddOrUpdate(CustProdDb); db.CustomerProdcut.Add(CustomerProductToBeAdded); db.SaveChanges(); return(Json("Done")); } ViewBag.CustomerId = new SelectList(db.Customers, "Id", "Name", CustomerProductToBeAdded.CustomerId); ViewBag.ProdcutId = new SelectList(db.CategoryProduct, "Id", "Name", CustomerProductToBeAdded.CategoryProductId); return(View(CustomerProductToBeAdded)); }