public ActionResult removeSupplier(int id) { SupplierInvItem supInv = db.SupplierInvItems.Find(id); db.SupplierInvItems.Remove(supInv); db.SaveChanges(); return(RedirectToAction("Index", "InvItems", null)); }
public ActionResult RemoveInvItems(int id) { SupplierInvItem item = db.SupplierInvItems.Find(id); db.SupplierInvItems.Remove(item); db.SaveChanges(); return(RedirectToAction("InvItems", "Suppliers", new { id = item.SupplierId })); }
public ActionResult AddSupplier(int id, int supId) { SupplierInvItem newSupInv = new SupplierInvItem(); newSupInv.InvItemId = id; newSupInv.SupplierId = supId; if (db.SupplierInvItems.Where(s => s.InvItemId == id).FirstOrDefault() != null) { newSupInv = db.SupplierInvItems.Where(s => s.InvItemId == id).FirstOrDefault(); newSupInv.SupplierId = supId; //update if record exist db.Entry(newSupInv).State = EntityState.Modified; } else { //add if record does not db.SupplierInvItems.Add(newSupInv); } db.SaveChanges(); return(RedirectToAction("Index", "InvItems", null)); }