/// <summary>
 /// Gets the last weeks worth of shifts for the current user.
 /// </summary>
 /// <param name="sessionID">The sessionID of the current session</param>
 /// <returns></returns>
 public List<ShiftData> GetLastWeeksShifts(string sessionID)
 {
     WorkerShiftsTableAdapter wta = new WorkerShiftsTableAdapter();
     var lastWeekShifts = wta.GetDataByEmployeeID(Auth.getEmployeeID(sessionID), DateTime.Now.Subtract(new TimeSpan(7, 0, 0, 0)));
     List<ShiftData> re = new List<ShiftData>();
     foreach (var shift in lastWeekShifts)
     {
         ShiftData sd = new ShiftData();
         sd.EmployeeID = shift.EmployeeID;
         if (shift.IsEndTimeNull()) sd.EndTime = null;
         else
             sd.EndTime = shift.EndTime;
         sd.StartTime = shift.StartTime;
         sd.Role = shift.Role;
         sd.ShiftID = shift.ID;
         if (sd.EndTime != null)
         {
             sd.HoursWorked = (decimal)sd.EndTime.Value.Subtract(sd.StartTime).TotalHours;
         }
         else
         {
             sd.HoursWorked = 0;
         }
         re.Add(sd);
     }
     return re;
 }
예제 #2
0
        /// <summary>
        /// Gets a list of the shifts for employees during a timeframe.
        /// </summary>
        /// <param name="sessionID">The sessionID of the current session</param>
        /// <param name="start">The start of the timeframe.</param>
        /// <param name="end">The end of the timeframe.</param>
        /// <returns></returns>
        public List<ShiftData> GetShiftsForEmployees(string sessionID, DateTime start, DateTime end)
        {
            List<ShiftData> re = new List<ShiftData>();
            WorkerShiftsTableAdapter wsa = new WorkerShiftsTableAdapter();
            var rows = wsa.GetDataByTimeFrame(start, end);
            foreach (var row in rows)
            {
                ShiftData sd = new ShiftData();
                sd.EmployeeID = row.EmployeeID;
                sd.StartTime = row.StartTime;
                if (row.IsEndTimeNull()) sd.EndTime = null;
                else
                    sd.EndTime = row.EndTime;
                sd.ShiftID = row.ID;
                sd.Role = row.Role;
                if (sd.EndTime != null)
                    sd.HoursWorked = (decimal)sd.EndTime.Value.Subtract(sd.StartTime).TotalHours;
                else
                    sd.HoursWorked = 0;

                re.Add(sd);
            }
            return re;
        }