コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            FoodInv foodInv = db.FoodInvs.Find(id);

            db.FoodInvs.Remove(foodInv);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        // 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));
        }
コード例 #4
0
ファイル: Player.cs プロジェクト: danilluk1/MVPFishing
 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);
     }
 }
コード例 #5
0
        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));
        }