//Index (works)
        public ActionResult GetWorkDay(DateTime dateTime, int departmentId)
        {
            if (departmentId == 0)
            {
                return(RedirectToAction("Index", null, null));
            }
            var shifts = _shiftRepository.GetShiftsWithWorkSelectedEmployeeWithDateTimeAndDepartment(dateTime, departmentId);

            if (shifts.Count == 0)
            {
                return(RedirectToAction("Index", null, null));
            }

            var ShiftResults = _shiftRepository.GetFirstShift(shifts);

            var shiftIds   = _shiftRepository.GetShiftTypesFromShifts(dateTime, departmentId);
            var shifttypes = _shiftTypeRepository.GetListFromShiftTypes(shiftIds);

            var employees = _employeeRepository.GetEmployeesWithDepartmentId(departmentId);

            var workDay = new GetWorkDayViewModel
            {
                Datetime      = ShiftResults.DateTime,
                DepartmentId  = departmentId,
                DepartemtName = ShiftResults.Department.Name,
                Shifts        = shifts,
                Departments   = _context.Departments.ToList(),
                ShiftTypes    = shifttypes,
                Employees     = employees,
            };

            return(View("GetWorkDay", workDay));
        }
Ejemplo n.º 2
0
        public ActionResult Index(DateTime?dateTime, int?departmentId)
        {
            var departments = new GetWorkDayViewModel
            {
                Departments = _context.Departments.ToList()
            };

            if (dateTime == null && departmentId == null)
            {
                return(View(departments));
            }
            else
            {
                var shiftIds   = _context.Shifts.Where(s => s.DateTime == dateTime && s.DepartmentId == departmentId).Select(s => s.ShiftTypeId).ToList();
                var shifttypes = _context.ShiftTypes.Where(t => shiftIds.Contains(t.Id)).ToList();
                return(RedirectToAction("GetWorkDay", new { currentDatetime = dateTime, currnetDpertmentId = departmentId, departmentsToList = departments, shiftToList = shifttypes }));
            }
        }
Ejemplo n.º 3
0
        //Index (works)
        public ActionResult GetWorkDay(DateTime dateTime, int departmentId)
        {
            if (departmentId == 0)
            {
                return(RedirectToAction("Index", null, null));
            }
            var shifts = _context.Shifts
                         .Include(s => s.Department)
                         .Include(s => s.ShiftType)
                         .Include(s => s.Works)
                         .Include(s => s.Works.Select(w => w.Employee))
                         .Where(s => s.DateTime == dateTime && s.DepartmentId == departmentId)
                         .ToList();

            if (shifts.Count == 0)
            {
                return(RedirectToAction("Index", null, null));
            }

            var ShiftResults = shifts.First();

            var shiftIds   = _context.Shifts.Where(s => s.DateTime == dateTime && s.DepartmentId == departmentId).Select(s => s.ShiftTypeId).ToList();
            var shifttypes = _context.ShiftTypes.Where(t => shiftIds.Contains(t.Id)).ToList();

            var employees = _context.Employees
                            .Where(e => e.DepartmentId == departmentId);

            var workDay = new GetWorkDayViewModel
            {
                Datetime      = ShiftResults.DateTime,
                DepartmentId  = departmentId,
                DepartemtName = ShiftResults.Department.Name,
                Shifts        = shifts,
                Departments   = _context.Departments.ToList(),
                ShiftTypes    = shifttypes,
                Employees     = employees,
            };

            return(View("GetWorkDay", workDay));
        }
        public ActionResult Index(DateTime?dateTime, int?departmentId)
        {
            var departments = new GetWorkDayViewModel
            {
                Departments = _departmentRepository.GetDepartments()
            };

            if (dateTime == null && departmentId == null)
            {
                return(View(departments));
            }
            else
            {
                var shiftIds   = _shiftRepository.GetShiftTypesFromShifts(dateTime, departmentId);
                var shifttypes = _shiftTypeRepository.GetListFromShiftTypes(shiftIds);
                return(RedirectToAction("GetWorkDay", new
                {
                    currentDatetime = dateTime,
                    currnetDpertmentId = departmentId,
                    departmentsToList = departments,
                    shiftToList = shifttypes
                }));
            }
        }