Example #1
0
        public ScheduleShift GetCurrentShift()
        {
            var shifts = new List <Setting>();

            shifts = db.Repository <Setting>().ReadAll().Where(a => a.SettingName.Contains("Opd_Shift_")).ToList();
            Setting.ShiftTime morningShiftTime   = new Setting.ShiftTime();
            Setting.ShiftTime afternoonShiftTime = new Setting.ShiftTime();
            Setting.ShiftTime dinnerShiftTime    = new Setting.ShiftTime();

            morningShiftTime.SetShiftTimeWithString(
                shifts.FirstOrDefault(a => a.SettingName == "Opd_Shift_Morning").Value);
            afternoonShiftTime.SetShiftTimeWithString(
                shifts.FirstOrDefault(a => a.SettingName == "Opd_Shift_Afternoon").Value);
            dinnerShiftTime.SetShiftTimeWithString(
                shifts.FirstOrDefault(a => a.SettingName == "Opd_Shift_Night").Value);

            switch (DateTime.Now)
            {
            case DateTime now when morningShiftTime.InThePeriod(now):
                return(ScheduleShift.Morning);

            case DateTime now when afternoonShiftTime.InThePeriod(now):
                return(ScheduleShift.Afternoon);

            case DateTime now when dinnerShiftTime.InThePeriod(now):
                return(ScheduleShift.Night);

            default:
                return(ScheduleShift.All);
            }
        }
Example #2
0
        public List <string> GetValidShift()
        {
            var validShift = new List <string>();
            var shifts     = new List <Setting>();

            shifts = db.Repository <Setting>().ReadAll().Where(a => a.SettingName.Contains("Opd_Shift_")).ToList();

            Setting.ShiftTime morningShiftTime   = new Setting.ShiftTime();
            Setting.ShiftTime afternoonShiftTime = new Setting.ShiftTime();
            Setting.ShiftTime dinnerShiftTime    = new Setting.ShiftTime();

            morningShiftTime.SetShiftTimeWithString(
                shifts.FirstOrDefault(a => a.SettingName == "Opd_Shift_Morning").Value);
            afternoonShiftTime.SetShiftTimeWithString(
                shifts.FirstOrDefault(a => a.SettingName == "Opd_Shift_Afternoon").Value);
            dinnerShiftTime.SetShiftTimeWithString(
                shifts.FirstOrDefault(a => a.SettingName == "Opd_Shift_Night").Value);

            switch (DateTime.Now)
            {
            case DateTime now when morningShiftTime.InThePeriod(now):
                validShift.Add(((int)ScheduleShift.Morning).ToString());

                break;

            case DateTime now when afternoonShiftTime.InThePeriod(now):
                validShift.Add(((int)ScheduleShift.Afternoon).ToString());

                break;

            case DateTime now when dinnerShiftTime.InThePeriod(now):
                validShift.Add(((int)ScheduleShift.Night).ToString());

                break;
            }
            return(validShift);
        }