public ActionResult EmpList() { EmployeeFinal empFinal = new EmployeeFinal(); empFinal.eMPLOYEE = null; empFinal.eMPLOYEELIST = db.EMPLOYEEs.ToList(); return(View(empFinal)); }
public ActionResult EmpCreate(EmployeeFinal empFinal) { EMPLOYEE employee = new EMPLOYEE(); // Retrieve form data using form collection employee.NAME = empFinal.eMPLOYEE.NAME; employee.CITY = empFinal.eMPLOYEE.CITY; employee.AGE = empFinal.eMPLOYEE.AGE; employee.DEPTID = empFinal.eMPLOYEE.DEPTID; db.EMPLOYEEs.Add(employee); db.SaveChanges(); return(RedirectToAction("EmpList")); }
public ActionResult EmpDelete(int id, EmployeeFinal collection) { try { db.EMPLOYEEs.Remove(db.EMPLOYEEs.FirstOrDefault(x => x.ID == id)); db.SaveChanges(); // TODO: Add delete logic here return(RedirectToAction("EmpList")); } catch { return(View()); } }
public ActionResult EmpEdit(int id, EmployeeFinal emp) { try { // TODO: Add update logic here EMPLOYEE emp1 = db.EMPLOYEEs.FirstOrDefault(x => x.ID == id); if (emp1 != null) { emp1.NAME = emp.eMPLOYEE.NAME; emp1.CITY = emp.eMPLOYEE.CITY; emp1.AGE = emp.eMPLOYEE.AGE; db.SaveChanges(); } return(RedirectToAction("EmpList", "Employee")); } catch { return(View()); } }