// // GET: /Customer/Edit/5 public ActionResult Edit(int id) { using (NEWTEMPDBEntities dbModel = new NEWTEMPDBEntities()) { return(View(dbModel.Customers.Where(x => x.ID == id).FirstOrDefault())); } }
// // GET: /Customer/ public ActionResult Index() { using (NEWTEMPDBEntities dbModel = new NEWTEMPDBEntities()) { return(View(dbModel.Customers.ToList())); } }
public ActionResult Edit(int id, Customer customer) { try { using (NEWTEMPDBEntities dbModel = new NEWTEMPDBEntities()) { dbModel.Entry(customer).State = System.Data.EntityState.Modified; dbModel.SaveChanges(); return(RedirectToAction("Index")); } } catch { return(View()); } }
public ActionResult Create(Customer customer) { try { using (NEWTEMPDBEntities dbModel = new NEWTEMPDBEntities()) { dbModel.Customers.Add(customer); dbModel.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(int id, FormCollection collection) { try { // TODO: Add delete logic here using (NEWTEMPDBEntities dbModel = new NEWTEMPDBEntities()) { Customer customer = dbModel.Customers.Where(x => x.ID == id).FirstOrDefault(); dbModel.Customers.Remove(customer); dbModel.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }