/// <summary> /// Edits a shift based on its shift number. /// </summary> /// <param name="sessionID">The sessionID of the current session</param> /// <param name="shiftNumber">The shift number to be edited.</param> /// <param name="EmployeeId">The new employee id.</param> /// <param name="role">The new role.</param> /// <param name="start">The new start time of the shift.</param> /// <param name="end">The new end time of the shift.</param> public void EditShift(string sessionID, int shiftNumber, int EmployeeId, string role, DateTime start, DateTime end) { WorkerShiftsTableAdapter wta = new WorkerShiftsTableAdapter(); wta.Update(start, end, role, EmployeeId, shiftNumber); }
/// <summary> /// Ends the shift of the given user if they are in a shift. /// </summary> /// <param name="sessionID">The sessionID of the current session</param> /// <returns> /// Returns true if the user's shift could be ended, else returns false /// </returns> public bool StampShiftEnd(string sessionID) { WorkerShiftsTableAdapter wta = new WorkerShiftsTableAdapter(); var lastStartTime = wta.GetDataByEmployeeID(Auth.getEmployeeID(sessionID), DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0))).FirstOrDefault(); EmployeeStatusTableAdapter est = new EmployeeStatusTableAdapter(); est.UpdateStatus(false, "", Auth.getEmployeeID(sessionID)); if (lastStartTime == null || !lastStartTime.IsEndTimeNull()) { return false; } else { lastStartTime.EndTime = DateTime.Now; wta.Update(lastStartTime); return true; } }