public EmployeeViewModel CreateEmp(EmployeeViewModel model)
        {
            CrudDemoDBEntities db = new CrudDemoDBEntities();

            if (model.EmpId > 0)
            {
                //update
                Employee emp = db.Employees.SingleOrDefault(x => x.EmpId == model.EmpId && x.IsActive == true);
                emp.Name         = model.Name;
                emp.Gender       = model.Gender;
                emp.DOB          = Convert.ToDateTime(model.DOB);
                emp.Address      = model.Address;
                emp.CityId       = model.CityId;
                emp.DepartmentId = model.DepartmentId;
                emp.IsActive     = model.IsActive;
                db.SaveChanges();


                //Employee emp = new Employee();
                //emp.Address = model.Address;
                //emp.Name = model.Name;
                //emp.DepartmentId = model.DepartmentId;

                //db.Employees.Add(emp);
                //db.SaveChanges();

                //int latestEmpId = emp.EmployeeId;


                //Site site = new Site();
                //site.SiteName = model.SiteName;
                //site.EmployeeId = latestEmpId;

                //db.Sites.Add(site);
                //db.SaveChanges();
            }
            else
            {
                //Insert
                Employee emp = new Employee();
                emp.Name    = model.Name;
                emp.Gender  = model.Gender;
                emp.DOB     = Convert.ToDateTime(model.DOB);
                emp.Address = model.Address;
                emp.CityId  = model.CityId;

                emp.DepartmentId = model.DepartmentId;
                emp.IsActive     = model.IsActive;
                db.Employees.Add(emp);
                db.SaveChanges();
            }
            return(model);
        }
        public void DeleteEmp(int EmployeeId)
        {
            CrudDemoDBEntities db = new CrudDemoDBEntities();

            Employee emp = db.Employees.SingleOrDefault(x => x.IsActive == true && x.EmpId == EmployeeId);

            if (emp != null)
            {
                emp.IsActive = false;
                db.SaveChanges();
            }

            //  return RedirectToAction("Index");
        }