public ActionResult DeleteConfirmed(int id) { AlcoholInv alcoholInv = db.AlcoholInvs.Find(id); db.AlcoholInvs.Remove(alcoholInv); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "Id,Brand,Type,Size,Price,Quantity")] AlcoholInv alcoholInv) { if (ModelState.IsValid) { db.AlcoholInvs.Add(alcoholInv); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(alcoholInv)); }
// GET: AlcoholInvs/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AlcoholInv alcoholInv = db.AlcoholInvs.Find(id); if (alcoholInv == null) { return(HttpNotFound()); } return(View(alcoholInv)); }
public ActionResult Edit([Bind(Include = "Id,Brand,Type,Size,Price,Quantity")] AlcoholInv alcoholInv) { if (ModelState.IsValid) { db.Entry(alcoholInv).State = EntityState.Modified; db.SaveChanges(); //if (alcoholInv.Quantity <= alcoholInv.purchaseLevel) //{ // var fromAddress = new MailAddress("*****@*****.**", "Best Friendz"); // var toAddress = new MailAddress("*****@*****.**", "Manager"); // const string fromPassword = "******"; // const string subject = "Low Beverage 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(alcoholInv)); }