Beispiel #1
0
 // Take in a string to determine which button was pressed
 public ActionResult ModifyItem(int Id, string submit)
 {
     if (submit == "delete")
     {
         using (InventoryItemContext db = new InventoryItemContext())
         {
             var item = db.InventoryItems.Find(Id);
             item.Removed = DateTime.Now;
             db.SaveChanges();
         }
         return(RedirectToAction("../Home/Index"));
     }
     else if (submit == "edit")
     {
         using (InventoryItemContext db = new InventoryItemContext())
         {
             var item = db.InventoryItems.Find(Id);
             return(View("../Edit/EditItem", item));
         }
     }
     else
     {
         return(RedirectToAction("../Home/Index"));
     }
 }
Beispiel #2
0
 public ActionResult EditItem(InventoryItem item)
 {
     using (InventoryItemContext db = new InventoryItemContext())
     {
         var itemToChange = db.InventoryItems.Find(item.Id);
         itemToChange.Name     = item.Name;
         itemToChange.Location = item.Location;
         itemToChange.Quantity = item.Quantity;
         db.SaveChanges();
     }
     return(RedirectToAction("../Home/Index"));
 }
Beispiel #3
0
 public ActionResult AddItem(string name, string location, int quantity)
 {
     using (InventoryItemContext db = new InventoryItemContext())
     {
         var item = new InventoryItem();
         item.Name     = name;
         item.Location = location;
         item.Quantity = quantity;
         db.InventoryItems.Add(item);
         db.SaveChanges();
     }
     return(RedirectToAction("../Home/Index"));
 }