Пример #1
0
        //this will determine if the user can take a break on this time
        //public static ResponseBreak IsBreakEnableTimeByType(int type, string uid, IScheduleService _scheduleService, DateTime time) {
        //    try {
        //        var response = new ResponseBreak() { message="", enabled=false};
        //        //var usched = AttendanceUtility.GetUserSchedule(uid, _scheduleService);
        //        var breaktime=new TimeSpan();
        //        var disabled=new TimeSpan();
        //        var currTime = time.TimeOfDay;
        //        switch (type) {
        //            case 1:
        //                breaktime = TimeCalculator.AddTime(usched.TimeIn.Value, new TimeSpan(1, 0, 0));
        //                disabled = TimeCalculator.AddTime(usched.TimeIn.Value, new TimeSpan(3, 0, 0));
        //                if (TimeCalculator.CheckIfWithinTheTime(breaktime,disabled,
        //                                                     currTime)) {
        //                    response.enabled = true;
        //                }
        //                break;
        //            case 2:
        //                breaktime = TimeCalculator.AddTime(usched.TimeIn.Value, new TimeSpan(3, 30, 0));
        //                disabled = TimeCalculator.AddTime(usched.TimeIn.Value, new TimeSpan(5, 0, 0));
        //                if (TimeCalculator.CheckIfWithinTheTime(breaktime,disabled,
        //                                                     currTime)){
        //                    response.enabled = true;
        //                }
        //                break;
        //            case 3:
        //                breaktime = TimeCalculator.AddTime(usched.TimeIn.Value, new TimeSpan(6, 0, 0));
        //                disabled = TimeCalculator.AddTime(usched.TimeIn.Value, new TimeSpan(8, 0, 0));

        //                if (TimeCalculator.CheckIfWithinTheTime(breaktime,disabled,
        //                                                     currTime)){
        //                    response.enabled = true;
        //                }
        //                break;
        //            default:
        //                response.enabled = true;
        //                break;
        //        }
        //        response.message = IsBreakLessOrGreatResponse(breaktime, disabled, currTime);
        //        return response;

        //    } catch { return null; }
        //}

        private static string IsBreakLessOrGreatResponse(TimeSpan basetime, TimeSpan ceilingTime, TimeSpan time)
        {
            if (TimeCalculator.CheckTimeIfGreater(time, ceilingTime))
            {
                return(MessageUtility.BreakTimeUnavailable());
            }
            else if (TimeCalculator.CheckTimeIfLess(time, basetime))
            {
                return(MessageUtility.ToSoonToTakeABreak());
            }
            return("");
        }