public async Task <ActionResult <OrderSupply> > PostOrderSupply(OrderSupply orderSupply) { _context.OrderSupply.Add(orderSupply); await _context.SaveChangesAsync(); return(CreatedAtAction("GetOrderSupply", new { id = orderSupply.Id }, orderSupply)); }
public async Task <IActionResult> PutOrderSupply(Guid id, OrderSupply orderSupply) { if (id != orderSupply.Id) { return(BadRequest()); } _context.Entry(orderSupply).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderSupplyExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public PartialViewResult DeleteConfirmed(int id) { OrderSupply orderSupply = db.OrderSupplies.Find(id); db.OrderSupplies.Remove(orderSupply); db.SaveChanges(); return(PartialView("~/Views/Admin/OrderSupplies.cshtml", db.OrderSupplies.ToList())); }
public ActionResult DeleteConfirmed(int id) { OrderSupply orderSupply = db.OrderSupplies.Find(id); db.OrderSupplies.Remove(orderSupply); db.SaveChanges(); return(RedirectToAction("Index")); }
public PartialViewResult Edit([Bind(Include = "OrderSupplyID,Name,Time,Price")] OrderSupply orderSupply) { if (ModelState.IsValid) { db.Entry(orderSupply).State = EntityState.Modified; db.SaveChanges(); return(PartialView("~/Views/Admin/OrderSupplies.cshtml", db.OrderSupplies.ToList())); } return(PartialView()); }
public ActionResult Edit([Bind(Include = "orderId,OrderNum,supplier,supplierEmail,suplyNum,itemQty,ProductsList,NumOfProdOrdered,orderedBy,totalOrder,dateOrdered,status,isOrdered")] OrderSupply orderSupply) { if (ModelState.IsValid) { db.Entry(orderSupply).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(orderSupply)); }
public PartialViewResult Create([Bind(Include = "OrderSupplyID,Name,Time,Price")] OrderSupply orderSupply) { if (ModelState.IsValid) { db.OrderSupplies.Add(orderSupply); db.SaveChanges(); return(PartialView("~/Views/Admin/OrderSupplies.cshtml", db.OrderSupplies.ToList())); } return(PartialView()); }
public ActionResult confirmStock(int id) { OrderSupply o = db.OrderSupplies.ToList().Where(x => x.orderId == id).FirstOrDefault(); InventoryProduct i = db.Products.ToList().Where(x => x.productName == o.ProductsList).FirstOrDefault(); i.quantityOnHand = i.quantityOnHand + o.itemQty; i.status = "In Stock"; o.status = "Delivered"; db.SaveChanges(); return(RedirectToAction("Index", "OrderSupplies")); }
// GET: OrderSupplies/Delete/5 public PartialViewResult Delete(int?id) { if (id == null) { //return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } OrderSupply orderSupply = db.OrderSupplies.Find(id); if (orderSupply == null) { //return HttpNotFound(); } return(PartialView(orderSupply)); }
// GET: OrderSupplies/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OrderSupply orderSupply = db.OrderSupplies.Find(id); if (orderSupply == null) { return(HttpNotFound()); } return(View(orderSupply)); }
public ActionResult placeOrder(InventoryProductList model) { var checkinSelected = model.inventory.Where(a => a.isOrdered == true).ToList(); if (checkinSelected == null || checkinSelected.Count < 1) { return(RedirectToAction("Alert")); } var selectedProd = model.inventory.Where(x => x.isOrdered == true).ToList(); string productsOrdered = ""; string supplierName = ""; string suplierEmail = ""; string managerEmail = User.Identity.GetUserName(); foreach (InventoryProduct v in selectedProd) { OrderSupply o = new OrderSupply(); o.supplierEmail = db.Suppliers.ToList().Where(x => x.supplierid == v.SupplierId).FirstOrDefault().supplierEmail; o.supplier = db.Suppliers.ToList().Where(x => x.supplierid == v.SupplierId).FirstOrDefault().supplierName; o.suplyNum = db.Suppliers.ToList().Where(x => x.supplierid == v.SupplierId).FirstOrDefault().supplierNumber; o.itemQty = db.Products.ToList().Where(x => x.productId == v.productId).FirstOrDefault().quantityToOrder; o.totalOrder = (db.Products.ToList().Where(x => x.productId == v.productId).FirstOrDefault().quantityToOrder) * (db.Products.ToList().Where(x => x.productId == v.productId).FirstOrDefault().prevUnitPrice); o.dateOrdered = DateTime.Now.ToString(); o.ProductsList = db.Products.ToList().Where(x => x.productId == v.productId).FirstOrDefault().productName; o.status = "Pending"; o.isOrdered = true; o.orderedBy = User.Identity.GetUserName(); suplierEmail = db.Suppliers.ToList().Where(x => x.supplierid == v.SupplierId).FirstOrDefault().supplierEmail; supplierName = db.Suppliers.ToList().Where(x => x.supplierid == v.SupplierId).FirstOrDefault().supplierName; productsOrdered += $" { o.ProductsList} ({o.itemQty}), "; InventoryProduct pp = db.Products.ToList().Where(x => x.productId == v.productId).FirstOrDefault(); pp.status = "Ordered"; db.OrderSupplies.Add(o); db.SaveChanges(); } if (suplierEmail != null) { string msg = $"Hi {supplierName}. We would like to order the following products { productsOrdered } Contact us at [email protected] for enquiries."; emailhelper.sendMail(suplierEmail, "Placing new order", msg); string newMsg = $"Hi you have placed an order to { supplierName} for the following products { productsOrdered } Contact us at [email protected] for enquiries."; emailhelper.sendMail(managerEmail, "Placed new order", newMsg); } return(View("addProdSuc")); }