public ActionResult DeleteConfirmed(int id) { tblStorage tblStorage = db.tblStorages.Find(id); db.tblStorages.Remove(tblStorage); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "StorageId,Storage")] tblStorage tblStorage) { if (ModelState.IsValid) { db.Entry(tblStorage).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblStorage)); }
public ActionResult Create([Bind(Include = "StorageId,Storage")] tblStorage tblStorage) { if (ModelState.IsValid) { db.tblStorages.Add(tblStorage); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblStorage)); }
// GET: Storages/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblStorage tblStorage = db.tblStorages.Find(id); if (tblStorage == null) { return(HttpNotFound()); } return(View(tblStorage)); }
private void StoreExecute() { Delegate d = new Delegate(); try { using (Context context = new Context()) { //if there is enough space, because capacity is 100 if (Suma + Product.Amount <= 100) { tblStorage newStorage = new tblStorage(); newStorage.ProductID = Product.ProductID; newStorage.Price = Product.Amount; context.tblStorages.Add(newStorage); tblProduct productToStore = (from r in context.tblProducts where r.ProductID == Product.ProductID select r).First(); //changing bool propertie (stored) to true productToStore.Stored = true; context.SaveChanges(); //MessageBox.Show("Product is stored in warehouse"); //DELEGATE implementation d.ProductStored(); //updating list and sum ListProduct = GetProducts(); Suma = GetSum(); } else { //MessageBox.Show("Warehouse capacity is 100. There is not enough free space"); //DELEGATE implementation d.WarehouseFull(); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }