// GET: Customer/Delete/5 public ActionResult Delete(int id) { using (Customer1Entities ce = new Customer1Entities()) { return(View(ce.Customers.Where(x => x.Id == id).FirstOrDefault())); } }
// GET: Customer/Index public ActionResult Index() { using (Customer1Entities ce = new Customer1Entities()) { return(View(ce.Customers.ToList())); } }
public ActionResult Edit(int id, Customer c) { try { // TODO: Add update logic here using (Customer1Entities ce = new Customer1Entities()) { ce.Entry(c).State = EntityState.Modified; ce.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(Customer c) { try { // TODO: Add insert logic here using (Customer1Entities ce = new Customer1Entities()) { ce.Customers.Add(c); ce.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(int id, Customer customer) { try { // TODO: Add delete logic here using (Customer1Entities ce = new Customer1Entities()) { customer = ce.Customers.Where(x => x.Id == id).FirstOrDefault(); ce.Customers.Remove(customer); ce.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }