public ActionResult Edit(int id, Customers1 customer) { try { using (DatabaseDataTableEntities2 dbModel = new DatabaseDataTableEntities2()) { dbModel.Entry(customer).State = EntityState.Modified; dbModel.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(int id, FormCollection collection) { try { using (DatabaseDataTableEntities2 dbModel = new DatabaseDataTableEntities2()) { Customers1 customers = dbModel.Customers1.Where(x => x.CustomerID == id).FirstOrDefault(); dbModel.Customers1.Remove(customers); dbModel.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(Customers1 customer) { try { using (DatabaseDataTableEntities2 dbModel = new DatabaseDataTableEntities2()) { dbModel.Customers1.Add(customer); dbModel.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }