public async Task <HttpResponseMessage> GetAllDelegationRequest(HttpRequestMessage request, string userID, string groupID, string column, bool isDesc, int page, int pageSize) { Func <HttpResponseMessage> func = () => { if (string.IsNullOrEmpty(userID) || string.IsNullOrEmpty(groupID)) { return(request.CreateErrorResponse(HttpStatusCode.BadRequest, nameof(userID) + MessageSystem.NoValues + nameof(groupID) + MessageSystem.NoValues)); } var model = _delegationRequestService.GetAllDelegationRequest(userID, groupID); foreach (var item in model) { if (item.StatusRequest.Name == CommonConstants.StatusDelegation) { _requestService.CheckDataDelegationRequest(groupID, item); } } var lstDelegationRequest = _delegationRequestService.GetAllDelegationRequest(userID, groupID); var data = lstDelegationRequest.OrderByField(column, isDesc).Skip((page - 1) * pageSize).Take(pageSize); var responseData = Mapper.Map <IEnumerable <Request>, IEnumerable <RequestViewModel> >(data); var paginationSet = new PaginationSet <RequestViewModel>() { Items = responseData, PageIndex = page, TotalRows = model.Count(), PageSize = pageSize }; return(request.CreateResponse(HttpStatusCode.OK, paginationSet)); }; return(await CreateHttpResponse(request, func)); }