Пример #1
0
        public ActionResult Delete(int depID)
        {
            var t        = new project1.Models.Project1DBEntities();
            var temp_dep = t.Departments.First(g => g.ID == depID);

            return(View(temp_dep));
        }
Пример #2
0
        // GET: Department

        public ActionResult Index()
        {
            var t = new project1.Models.Project1DBEntities();
            List <Models.Department> departments = t.Departments.ToList();

            return(View(departments));
        }
        public ActionResult Delete(int empID)
        {
            var t        = new project1.Models.Project1DBEntities();
            var temp_emp = t.Employee1.First(g => g.ID == empID);

            return(View(temp_emp));
        }
Пример #4
0
        public ActionResult Add(Department dep)
        {
            var t = new project1.Models.Project1DBEntities();

            t.Departments.Add(dep);
            t.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(int empID)
        {
            var t        = new project1.Models.Project1DBEntities();
            var employee = t.Employee1.Include("Department").FirstOrDefault(emp => emp.ID == empID);

            ViewData.Add("DepartmentsList", t.Departments.ToList());
            return(View(employee));
        }
Пример #6
0
        public ActionResult Delete(int depID, int managerID)
        {
            var t        = new project1.Models.Project1DBEntities();
            var temp_dep = t.Departments.First(g => g.ID == depID && g.Manager == managerID);

            t.Departments.Remove(temp_dep);
            t.SaveChanges();
            return(View(temp_dep));
        }
Пример #7
0
        public ActionResult Edit(Department dep)
        {
            var t        = new project1.Models.Project1DBEntities();
            var temp_dep = t.Departments.First(g => g.ID == dep.ID);

            temp_dep.Manager = dep.Manager;
            temp_dep.Name    = dep.Name;
            t.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #8
0
        public ActionResult Edit(int depID)
        {
            var t   = new project1.Models.Project1DBEntities();
            var dep = t.Departments.FirstOrDefault(g => g.ID == depID);

            if (dep != null)
            {
                return(View(dep));
            }
            return(View());
        }
        public ActionResult Delete(int empID, int usr)
        {
            var t        = new project1.Models.Project1DBEntities();
            var temp_emp = t.Employee1.First(g => g.ID == empID);
            var shifts   = t.EmployeeShifts.Where(g => g.EmployeeID == empID).ToList();

            t.Employee1.Remove(temp_emp);
            t.EmployeeShifts.RemoveRange(shifts);
            t.SaveChanges();
            return(View(temp_emp));
        }
        public ActionResult Edit(Employee1 emp1)
        {
            var t        = new project1.Models.Project1DBEntities();
            var employee = t.Employee1.Include("Department").FirstOrDefault(emp => emp.ID == emp1.ID);

            employee.FirstName     = emp1.FirstName;
            employee.LastName      = emp1.LastName;
            employee.StartWorkYear = emp1.StartWorkYear;
            employee.DepartmentID  = emp1.DepartmentID;
            t.SaveChanges();
            return(RedirectToAction("HomePage"));
        }
        // GET: Employee
        public ActionResult HomePage(string search)
        {
            var t = new project1.Models.Project1DBEntities();
            List <Models.Employee1> employees = t.Employee1.ToList();

            if (!string.IsNullOrEmpty(search))
            {
                employees = t.Employee1.Include("Department").
                            Where(g => g.FirstName.ToLower().Contains(search.ToLower()) ||
                                  g.LastName.ToLower().Contains(search.ToLower()) ||
                                  g.Department.Name.ToLower().Contains(search.ToLower())).ToList();
            }
            return(View(employees));
        }