public ActionResult DeleteConfirmed(int emp_id) { ImportExcelDBEntities db = new ImportExcelDBEntities(); Employee employee = db.Employees.Find(emp_id); db.Employees.Remove(employee); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Employee employee) { if (ModelState.IsValid) { ImportExcelDBEntities db = new ImportExcelDBEntities(); db.Employees.Add(employee); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employee)); }
public ActionResult Edit(Employee employee) { if (ModelState.IsValid) { ImportExcelDBEntities db = new ImportExcelDBEntities(); db.Entry(employee).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employee)); }
public ActionResult ImportData(List <Employee> employees) { bool status = false; if (ModelState.IsValid) { using (ImportExcelDBEntities db = new ImportExcelDBEntities()) { foreach (var i in employees) { db.Employees.Add(i); } db.SaveChanges(); status = true; } } return(new JsonResult { Data = new { status = status } }); }