Ejemplo n.º 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;
     }));
 }