protected async override Task OnInitializedAsync() { var authState = await AuthenticationStateTask; if (int.TryParse(authState.User.Claims.Where(s => s.Type == "UserId").Select(s => s.Value).FirstOrDefault(), out int userId)) { LoggedInUser = await UserService.GetUser(userId); } Shifts = ShiftDetailService.GetAllShifts(); foreach (ShiftModel shift in Shifts) { foreach (ShiftDetailModel shiftDetails in shift.ShiftDetails) { UserModel employee = await UserService.GetUserByIdAsync(shiftDetails.PickedByEmployee); // creating new aobject of shiftReportModel ShiftReportModel shiftReportModel = new ShiftReportModel(); shiftReportModel.FirstName = employee.FirstName; shiftReportModel.LastName = employee.LastName; shiftReportModel.UserName = employee.UserName; shiftReportModel.StartTime = shift.StartTime; shiftReportModel.EndTime = shift.EndTime; shiftReportModel.Date = shift.StartTime.Date; // adding items to shiftReportModel list AllShiftReports.Add(shiftReportModel); } } }
/// <summary> /// This method is called when the page is loaded /// </summary> protected async override Task OnInitializedAsync() { var authState = await AuthenticationStateTask; if (int.TryParse(authState.User.Claims.Where(s => s.Type == "UserId").Select(s => s.Value).FirstOrDefault(), out int userId)) { LoggedInUser = await UserService.GetUser(userId); } //converting times based on US Mountain standard time, as it does not get the correct time when deployed to azure var currentTimeZone = TimeZoneInfo.FindSystemTimeZoneById("US Mountain Standard Time"); Today = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, currentTimeZone); AllShiftDetails = ShiftDetailService.GetAllShiftsForEmployee(LoggedInUser.Id); AllShifts = AllShiftDetails.Select(s => s.Shift).ToList(); }
/// <summary> /// Selecting the shift as an employee /// </summary> /// <param name="shiftId"></param> protected async Task SelectedShiftAsEmployee(int shiftId) { if (LoggedInUser.RoleId == 4) { ShiftDetailModel shiftDetail = new ShiftDetailModel { PickedByEmployee = LoggedInUser.Id, ShiftId = shiftId }; ShiftDetailService.AddShiftDetail(shiftDetail); //signal r sending real time changes if (IsConnected) { await SendMessage(); } } }
/// <summary> /// MEthod to Cancel the shift as an Employee /// </summary> /// <param name="shiftDetail"></param> protected void CancelShiftDetails(ShiftDetailModel shiftDetail) { ShiftDetailService.CancelShiftDetail(shiftDetail); }
/// <summary> /// Method to Disapprove the Cancellation as a supervisor/manager /// </summary> /// <param name="shiftDetailModel"></param> protected void DisapproveCancellation(ShiftDetailModel shiftDetailModel) { //set the iscancelRequest of the shiftdetail to false ShiftDetailService.DisapproveCancelShiftDetail(shiftDetailModel); }
/// <summary> /// Method to Approve the Cancellation as a supervisor/manager /// </summary> /// <param name="shiftDetailModel"></param> protected void ApproveCancellation(ShiftDetailModel shiftDetailModel) { //delete the shift details ShiftDetailService.DeleteShiftDetail(shiftDetailModel); }
/// <summary> /// This method is called when the page is loaded /// </summary> protected override void OnInitialized() { AllCancellationRequests = ShiftDetailService.GetCancelshiftRequests(); }