/// <summary> /// Bind data explanation list to view model /// </summary> /// <param name="userId">id of user logged</param> /// <param name="groupId">groupId of user logged</param> /// <param name="column">name of column to sort</param> /// <param name="isDesc">parameter to check to sort by asc or desc</param> /// <param name="page">current page(use in paging)</param> /// <param name="pageSize">number of page showing(use in paging)</param> /// <param name="filter">list conditions to filter</param> /// <returns> explanations list as view model type </returns> public List <ExplanationRequestViewModel> GetExplanationListViewModel(string userId, string groupId, string column, bool isDesc, int page, int pageSize, FilterExplanationViewModel filter) { List <ExplanationRequestViewModel> listModel = new List <ExplanationRequestViewModel>(); // get explanation list var model = _explanationRequestService.GetExplanationsList(userId, groupId, column, isDesc, page, pageSize, filter); // bind data to view model foreach (var item in model) { listModel.Add(new ExplanationRequestViewModel { ID = item.ID, Title = item.Title, User = new AppUserViewModel { Id = item.AppUserCreatedBy.Id, FullName = item.AppUserCreatedBy.FullName, Email = item.AppUserCreatedBy.Email, Group = new GroupViewModel { Name = item.FingerTimeSheet.FingerMachineUsers.AppUser.Group.Name } }, Receiver = new AppUserViewModel { Id = item.Receiver.Id, FullName = item.Receiver.FullName }, ReasonDetail = item.ReasonDetail, CreatedDate = (DateTime)item.CreatedDate, ExplanationDate = item.FingerTimeSheet.DayOfCheck, StatusRequest = new StatusRequestViewModel { ID = item.StatusRequest.ID, Name = item.StatusRequest.Name }, Approver = item.UpdatedBy != null ? new AppUserViewModel { Id = item.AppUserUpdatedBy.Id, FullName = item.AppUserUpdatedBy.FullName } : new AppUserViewModel { }, AbnormalReason = _explanationRequestService.GetAbnormalById(item.TimeSheetId).Select(m => new AbnormalCaseReasonViewModel { ReasonId = m.AbnormalReason.ID, ReasonName = m.AbnormalReason.Name }).ToList() }); } return(listModel); }
public void ExplanationListTest1() { var list = explanationService.GetExplanationsList(userId2, groupId1, column, isDesc, page, pageSize, null); Assert.AreEqual(5, list.Count()); }