Esempio n. 1
0
        public ActionResult EmpList()
        {
            EmployeeFinal empFinal = new EmployeeFinal();

            empFinal.eMPLOYEE     = null;
            empFinal.eMPLOYEELIST = db.EMPLOYEEs.ToList();
            return(View(empFinal));
        }
Esempio n. 2
0
        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"));
        }
Esempio n. 3
0
        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());
            }
        }
Esempio n. 4
0
 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());
     }
 }