Exemplo n.º 1
0
        public DailySchedule GetSchedule(DateTime date)
        {
            DailySchedule                       schedule              = new DailySchedule(date);
            Table <DAL.Schedule>                scheduleTable         = GetScheduleTable();
            Table <DAL.WorkingCashier>          cashierTable          = GetWorkingCashierTable();
            Table <DAL.WorkingManager>          managerTable          = GetWorkingManagerTable();
            Table <DAL.WorkingRegularStaff>     staffTable            = GetWorkingRegularStaffTable();
            Table <DAL.WorkingWarehouseManager> warehouseManagerTable = GetWorkingWarehouseManagerTable();

            var matchedScheduleInDate = (from sch in scheduleTable
                                         where date.Date.CompareTo(sch.date) == 0
                                         select sch).ToList();

            foreach (DAL.Schedule matchedData in matchedScheduleInDate)
            {
                WorkingShift newShift       = new WorkingShift(matchedData.workingShiftID);
                var          matchedCashier = (from cashier in cashierTable
                                               where matchedData.scheduleID == cashier.scheduleID
                                               select cashier.staffID).ToList();
                foreach (string cashierID in matchedCashier)
                {
                    newShift.AddWorkingStaff(staffManager.GetStaff(cashierID));
                }

                var matchedManager = (from manager in managerTable
                                      where matchedData.scheduleID == manager.scheduleID
                                      select manager.staffID).ToList();
                foreach (string managerID in matchedManager)
                {
                    newShift.AddWorkingStaff(staffManager.GetStaff(managerID));
                }

                var matchedStaff = (from staff in staffTable
                                    where matchedData.scheduleID == staff.scheduleID
                                    select staff.staffID).ToList();
                foreach (string staffID in matchedStaff)
                {
                    newShift.AddWorkingStaff(staffManager.GetStaff(staffID));
                }

                var matchedKeeper = (from keeper in warehouseManagerTable
                                     where matchedData.scheduleID == keeper.scheduleID
                                     select keeper.staffID).ToList();
                foreach (string keeperID in matchedKeeper)
                {
                    newShift.AddWorkingStaff(staffManager.GetStaff(keeperID));
                }

                schedule.AddWorkingShift(newShift);
            }

            return(schedule);
        }