public void DeleteEmployee(int id,EmployeeInfo Emp)
 {
     var e = ctx.EmployeeInfoes.Find(id);
     if (e != null)
     {
         ctx.EmployeeInfoes.Remove(e);
         ctx.SaveChanges();
     }
 }
 public ActionResult Delete(int id, EmployeeInfo Emp)
 {
     try
     {
         obj.DeleteEmployee(id, Emp);
         return RedirectToAction("Index");
     }
     catch
     {
         return View(Emp);
     }
 }
        public ActionResult Create(EmployeeInfo Emp)
        {
            try
            {
                if (obj.CheckEmpNameExist(Emp.EmpName) == true && obj.CheckValidSal(Emp.Salary))
                {
                    obj.AddNewEmployee(Emp);
                    return RedirectToAction("Index");
                }
                else {
                    return View(Emp);

                }
            }
            catch
            {
                return View(Emp);
            }
        }
 // GET: EmployeeInfo/Create
 public ActionResult Create()
 {
     var Emp = new EmployeeInfo();
     return View(Emp);
 }
 public ActionResult Edit(int id, EmployeeInfo Emp)
 {
     try
     {
         obj.UpdateEmployee(id, Emp);
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
        public void UpdateEmployee(int id, EmployeeInfo Emp)
        {
            var e = ctx.EmployeeInfoes.Find(id);
            if (e != null)
            {
                e.EmpName = Emp.EmpName;
                e.Salary = Emp.Salary;
                e.DeptName = Emp.DeptName;
                e.Designation = Emp.Designation;

                ctx.SaveChanges();
            }
        }
 public void AddNewEmployee(EmployeeInfo Emp)
 {
     ctx.EmployeeInfoes.Add(Emp);
     ctx.SaveChanges();
 }