public ActionResult Edit(int id, customerdetail customer) { try { // TODO: Add update logic here using (CustomerModels cst = new CustomerModels()) { cst.Entry(customer).State = EntityState.Modified; cst.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(customerdetail customer) { try { using (CustomerModels cst = new CustomerModels()) { cst.customerdetails.Add(customer); cst.SaveChanges(); } // TODO: Add insert logic here return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(int id, FormCollection collection) { try { using (CustomerModels cd = new CustomerModels()) //modelname { customerdetail customer = cd.customerdetails.Where(x => x.id == id).FirstOrDefault(); //tablenmame searching id from table name cd.customerdetails.Remove(customer); //table name cd.SaveChanges(); } // TODO: Add delete logic here return(RedirectToAction("Index")); } catch { return(View()); } }