コード例 #1
0
 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;
     }));
 }
コード例 #2
0
        public async Task <HttpResponseMessage> GetAllDelegationExplanationRequest(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 = GetExplanationRequestViewModel(userID, groupID, column, isDesc, page, pageSize);
                foreach (var item in model)
                {
                    if (item.StatusRequest.Name == CommonConstants.StatusDelegation)
                    {
                        _explanationRequestService.CheckDataDelegationExplanationRequest(Convert.ToInt32(groupID), item.ID);
                    }
                }
                _explanationRequestService.Save();
                var lstDelegationExplanationRequest = GetExplanationRequestViewModel(userID, groupID, column, isDesc, page, pageSize);
                var data          = lstDelegationExplanationRequest.OrderByField(column, isDesc).Skip((page - 1) * pageSize).Take(pageSize);
                var paginationSet = new PaginationSet <ExplanationRequestViewModel>()
                {
                    Items     = data,
                    PageIndex = page,
                    TotalRows = lstDelegationExplanationRequest.Count(),
                    PageSize  = pageSize
                };
                return(request.CreateResponse(HttpStatusCode.OK, paginationSet));
            };

            return(await CreateHttpResponse(request, func));
        }