public ActionResult DeleteConfirmed(int id) { FoodInv foodInv = db.FoodInvs.Find(id); db.FoodInvs.Remove(foodInv); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "Id,Item,Description,Size,Price,Quantity")] FoodInv foodInv) { if (ModelState.IsValid) { db.FoodInvs.Add(foodInv); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(foodInv)); }
// GET: FoodInvs/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } FoodInv foodInv = db.FoodInvs.Find(id); if (foodInv == null) { return(HttpNotFound()); } return(View(foodInv)); }
public bool Eat(Food food) { if (food != null) { if (Satiety + food.Productivity <= SATIETY_MAX_VALUE) { Satiety += food.Productivity; FoodInv.Remove(food); AddEventToHistory(new FoodEvent(food)); SatietyUpdated.Invoke(food.Productivity); return(true); } else { MessageBox.Show(@"Игрок не достаточно голоден, чтобы съесть это"); return(false); } } else { return(false); } }
public ActionResult Edit([Bind(Include = "Id,Item,Description,Size,Price,Quantity")] FoodInv foodInv) { if (ModelState.IsValid) { db.Entry(foodInv).State = EntityState.Modified; db.SaveChanges(); //if (foodInv.Quantity <= foodInv.purchaseLevel) //{ // var fromAddress = new MailAddress("*****@*****.**", "Best Friendz"); // var toAddress = new MailAddress("*****@*****.**", "Manager"); // const string fromPassword = "******"; // const string subject = "Low Food 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(foodInv)); }