public void ExplanationListbyFilterTest9() { filter = new FilterExplanationViewModel { StatusRequest = new string[] { "3" }, ReasonRequest = new string[] { "4" }, FromDate = "01/01/2018", ToDate = "08/04/2018" }; var list = explanationService.GetExplanationsList(userId2, groupId1, column, isDesc, page, pageSize, filter); Assert.AreEqual(0, list.Count()); }
public async Task <HttpResponseMessage> GetExplanationsList(HttpRequestMessage request, string userId, string groupId, string column, bool isDesc, int page, int pageSize, [FromBody] FilterExplanationViewModel filter) { return(await CreateHttpResponse(request, () => { if (string.IsNullOrEmpty(userId) || string.IsNullOrEmpty(groupId)) { return request.CreateErrorResponse(HttpStatusCode.BadRequest, nameof(userId) + MessageSystem.NoValues + nameof(groupId) + MessageSystem.NoValues); } //var model = GetExplanationListViewModel(userId, groupId, column, isDesc, page, pageSize, filter); var model = _explanationRequestService.GetListOrigin(userId, groupId); var user = AppUserManager.Users.Where(x => x.Id.Equals(userId)).FirstOrDefault(); foreach (var item in model) { if (item.StatusRequest.Name == CommonConstants.StatusDelegation) { _explanationRequestService.CheckDataDelegationExplanationRequest(Convert.ToInt32(user.GroupId), item.ID); } } _explanationRequestService.Save(); var data = GetExplanationListViewModel(userId, groupId, column, isDesc, page, pageSize, filter); data = CheckExpireDate(data); PaginationSet <ExplanationRequestViewModel> pagedSet = new PaginationSet <ExplanationRequestViewModel>() { PageIndex = page, PageSize = pageSize, TotalRows = _explanationRequestService.GetTotalEntries(), Items = data, }; HttpResponseMessage response = request.CreateResponse(HttpStatusCode.OK, pagedSet); return response; })); }
/// <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> GetExplanationListForSuperAdmin(string column, bool isDesc, int page, int pageSize, FilterExplanationViewModel filter) { List <ExplanationRequestViewModel> listModel = new List <ExplanationRequestViewModel>(); // get explanation list var model = _explanationRequestService.GetExplanationsListForSuperAdmin(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 async Task <HttpResponseMessage> GetAllExplanationsList(HttpRequestMessage request, string column, bool isDesc, int page, int pageSize, [FromBody] FilterExplanationViewModel filter) { return(await CreateHttpResponse(request, () => { var model = GetExplanationListForSuperAdmin(column, isDesc, page, pageSize, filter); PaginationSet <ExplanationRequestViewModel> pagedSet = new PaginationSet <ExplanationRequestViewModel>() { PageIndex = page, PageSize = pageSize, TotalRows = _explanationRequestService.GetTotalEntries(), Items = model, }; HttpResponseMessage response = request.CreateResponse(HttpStatusCode.OK, pagedSet); return response; })); }