public ActionResult Edit([Bind(Include = "Id,ProductName,Price,Quantity,TotalQuantity,AvailableQuantity,TotalAmount,Datetime,SupplierId")] SuppliedProduct suppliedProduct) { if (ModelState.IsValid) { db.Entry(suppliedProduct).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SupplierId = new SelectList(db.Suppliers, "Id", "Name", suppliedProduct.SupplierId); return(View(suppliedProduct)); }
// GET: SuppliedProducts/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SuppliedProduct suppliedProduct = db.SuppliedProducts.Find(id); if (suppliedProduct == null) { return(HttpNotFound()); } return(View(suppliedProduct)); }
// GET: SuppliedProducts/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SuppliedProduct suppliedProduct = db.SuppliedProducts.Find(id); if (suppliedProduct == null) { return(HttpNotFound()); } ViewBag.SupplierId = new SelectList(db.Suppliers, "Id", "Name", suppliedProduct.SupplierId); return(View(suppliedProduct)); }
public static SuppliedProduct SuppliedProduct(Action <SuppliedProduct> config = null) { var retVal = new SuppliedProduct { Id = Any.Int(), Category = Any.AlphanumericString(), Price = Any.Decimal(), Name = Any.CompanyName() }; if (config != null) { config(retVal); } return(retVal); }
public ActionResult DeleteConfirmed(int id) { try { SuppliedProduct suppliedProduct = db.SuppliedProducts.Find(id); db.SuppliedProducts.Remove(suppliedProduct); db.SaveChanges(); } catch (Exception) { return(RedirectToAction("Error", "Home")); } finally { } return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "Id,ProductName,Price,Quantity,TotalQuantity,AvailableQuantity,TotalAmount,Datetime,SupplierId")] SuppliedProduct suppliedProduct) { if (ModelState.IsValid) { var product = db.SuppliedProducts.FirstOrDefault(s => s.ProductName.ToLower() == suppliedProduct.ProductName.ToLower() && suppliedProduct.Price == s.Price && suppliedProduct.SupplierId == s.SupplierId); if (product != null) { product.Quantity = suppliedProduct.Quantity; product.AvailableQuantity += suppliedProduct.Quantity; product.TotalQuantity += suppliedProduct.Quantity; var totalamount = product.Price * suppliedProduct.Quantity; product.TotalAmount = totalamount; //var grandamount = product.Price * suppliedProduct.TotalQuantity; //product.GrandAmount = grandamount; } else { var totalamount = suppliedProduct.Price * suppliedProduct.Quantity; suppliedProduct.TotalAmount = totalamount; //var grandamount = product.Price * suppliedProduct.TotalQuantity; //product.GrandAmount = grandamount; suppliedProduct.Datetime = DateTime.Now; db.SuppliedProducts.Add(suppliedProduct); } db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SupplierId = new SelectList(db.Suppliers, "Id", "Name", suppliedProduct.SupplierId); return(View(suppliedProduct)); }
public IHttpActionResult PostSuppliedProduct([FromODataUri] int supplierId, [FromBody]int index, [ModelBinder]SuppliedProduct item) { if (!ModelState.IsValid) { return BadRequest(); } return Ok(); }