public ActionResult DeleteConfirmed(int id) { SupplyInv supplyInv = db.SupplyInvs.Find(id); db.SupplyInvs.Remove(supplyInv); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "Id,Item,Description,Size,Price,Quantity")] SupplyInv supplyInv) { if (ModelState.IsValid) { db.SupplyInvs.Add(supplyInv); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(supplyInv)); }
// GET: SupplyInvs/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SupplyInv supplyInv = db.SupplyInvs.Find(id); if (supplyInv == null) { return(HttpNotFound()); } return(View(supplyInv)); }
public ActionResult Edit([Bind(Include = "Id,Item,Description,Size,Price,Quantity")] SupplyInv supplyInv) { if (ModelState.IsValid) { db.Entry(supplyInv).State = EntityState.Modified; db.SaveChanges(); //if (supplyInv.Quantity <= supplyInv.purchaseLevel) //{ // var fromAddress = new MailAddress("*****@*****.**", "Best Friendz"); // var toAddress = new MailAddress("*****@*****.**", "Manager"); // const string fromPassword = "******"; // const string subject = "Low Supplies Inventory, please place order immediately"; // const string body = "Please check your inventory, item(s) have reached restock level, place order."; // var smtp = new SmtpClient // { // Host = "smtp.gmail.com", // Port = 587, // EnableSsl = true, // DeliveryMethod = SmtpDeliveryMethod.Network, // UseDefaultCredentials = false, // Credentials = new NetworkCredential(fromAddress.Address, fromPassword) // }; // using (var message = new MailMessage(fromAddress, toAddress) // { // Subject = subject, // Body = body // }) // { // smtp.Send(message); // } //} return(RedirectToAction("Index")); } return(View(supplyInv)); }