public async Task <JsonResult> IsUserOnBreak()
 {
     try {
         var list = UserBreakModelUtility.FilterByCompanyID(CurrentUser.CompanyID, _userBreakTimeService.GetAll().Result.ToList());
         list = UserBreakModelUtility.FilterByStartDateTime(GetCurrentTime(), list);
         list = UserBreakModelUtility.FilterByUserID(CurrentUser.ID, list);
         list = UserBreakModelUtility.FilterByIsFinished(false, list);
         var isOnBreak = list.FirstOrDefault();
         if (isOnBreak != null)
         {
             var vm             = UserBreakModelUtility.MToVM(isOnBreak);
             var timeDifference = TimeCalculator.SubtructTime(isOnBreak.StartDateTime.Value.TimeOfDay, GetCurrentTime().TimeOfDay);
             //data here is the difference of your break consumed
             return(Json(new { success = true, data = timeDifference, timeLimit = isOnBreak.BreakType.TimeLimit, type = isOnBreak.BreakType.id }, JsonRequestBehavior.AllowGet));
         }
         return(Json(new { success = false }, JsonRequestBehavior.AllowGet));
     } catch { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); }
 }
Example #2
0
 //gets the number of days from now to the day its updated
 public static List <User> FilterByNumberOfDaysUpdated(DateTime time, int days, List <User> list)
 {
     return(list.Where(u => TimeCalculator.SubtructTime(u.UpdatedAt.Value, time).Days >= days).ToList());
 }