public async Task GetPendingApproval_GetPending_Custforapproval() { //Arrange string userid = "222", userName = "******"; List <PendingApproval> objPenList = new List <PendingApproval>(); PendingApproval objpen = new PendingApproval(); objpen.UserID = userid; objpen.RequestID = ""; objpen.AadharNum = ""; objpen.AadharImage = Convert.FromBase64String(""); objpen.AddtionDocDetails = ""; objpen.AdditionalDocImage = Convert.FromBase64String(""); objPenList.Add(objpen); _eventRepoMock.Setup(x => x.GetPendingApprovalDB()).ReturnsAsync(objPenList); PendingApprovalResponse oblpenResponse = new PendingApprovalResponse(); oblpenResponse.ResponseMessage = "Sucess"; ApprovalResponse objApprovalResponse = new ApprovalResponse(); objApprovalResponse.UserID = userid; objApprovalResponse.RequestID = ""; objApprovalResponse.AadharNum = ""; objApprovalResponse.AadharImage = (""); objApprovalResponse.AddtionDocDetails = ""; objApprovalResponse.AdditionalDocImage = (""); oblpenResponse.response.Add(objApprovalResponse); //Act var customer = await _EventBookingService.GetPendingApproval(); //Assert Assert.Equal(oblpenResponse.ResponseMessage, customer.ResponseMessage); Assert.Equal(oblpenResponse.response[0].UserID, customer.response[0].UserID); Assert.Equal(oblpenResponse.response[0].Status, customer.response[0].Status); Assert.Equal(oblpenResponse.response[0].AadharImage, customer.response[0].AadharImage); Assert.Equal(oblpenResponse.response[0].AadharNum, customer.response[0].AadharNum); Assert.Equal(oblpenResponse.response[0].AdditionalDocImage, customer.response[0].AdditionalDocImage); Assert.Equal(oblpenResponse.response[0].AddtionDocDetails, customer.response[0].AddtionDocDetails); Assert.Equal(oblpenResponse.response[0].RequestID, customer.response[0].RequestID); }
public async Task GetPendingApproval_GetPending_Custforapproval() { //Arrange string userid = "222", userName = "******"; List <PendingApproval> objPenList = new List <PendingApproval>(); PendingApproval objpen = new PendingApproval(); objpen.UserID = userid; objpen.RequestID = ""; objpen.AadharNum = ""; objpen.AadharImage = Convert.FromBase64String(""); objpen.AddtionDocDetails = ""; objpen.AdditionalDocImage = Convert.FromBase64String(""); objPenList.Add(objpen); _eventDBMock.Setup(x => x.ExecuteAsyncTableSql <PendingApproval>("sp_getPendingforApproval")).ReturnsAsync(objPenList); PendingApprovalResponse oblpenResponse = new PendingApprovalResponse(); oblpenResponse.ResponseMessage = "Sucess"; ApprovalResponse objApprovalResponse = new ApprovalResponse(); objApprovalResponse.UserID = userid; objApprovalResponse.RequestID = ""; objApprovalResponse.AadharNum = ""; objApprovalResponse.AadharImage = (""); objApprovalResponse.AddtionDocDetails = ""; objApprovalResponse.AdditionalDocImage = (""); oblpenResponse.response.Add(objApprovalResponse); //Act var customer = await _eventBookingRepository.GetPendingApprovalDB(); //Assert Assert.NotNull(customer); }
public List <PendingApproval> GetPendingApprovals(RequestData request) { PendingApproval pa; var lst = new List <PendingApproval>(); int[] ids = null; var utLst = appObj.UserTimeSheet.Where(ut => ut.IsSubmitted == request.IsSubmitted).ToList(); if (!request.IncludeApproved) { utLst = utLst.Where(ut => ut.IsApproved == false).ToList(); } if (request.From != null && request.To != null) { ids = appObj.TimeSheetDateHours.Where(dh => dh.Date >= request.From && dh.Date <= request.To).Select(dh => dh.TimesheetId).Distinct().ToArray(); utLst = utLst.Where(l => ids.Contains(l.Id)).ToList(); } if (request.UserId > 0) { utLst = utLst.Where(l => l.UserId == request.UserId).ToList(); } utLst.ForEach(ut => { pa = new PendingApproval { UserName = appObj.Users.Where(u => u.Id == ut.UserId).FirstOrDefault().Name }; appObj.TimeSheetDateHours.Where(dh => dh.TimesheetId == ut.Id).ToList().ForEach(dh => { pa.TotalHours += dh.Hours; if (pa.TimeSheetId == 0) { pa.TimeSheetId = dh.TimesheetId; } }); pa.Status = ut.IsApproved ? "Approved" : ut.IsSubmitted ? "Approval Pending" : "Saved and Not Submitted"; pa.WeekRange = appObj.TimeSheetDateHours.Where(dh => dh.TimesheetId == ut.Id).Select(w => w.Date).Min().Value.ToString("MMM/dd/yyyy") + "-" + appObj.TimeSheetDateHours.Where(dh => dh.TimesheetId == ut.Id).Select(w => w.Date).Max().Value.ToString("MMM/dd/yyyy"); lst.Add(pa); }); return(lst); }