Exemple #1
0
 public IActionResult Get([FromBody] CyclicOperationGetRequest query)
 => ReturnBadRequestIfThrowError(() =>
 {
     var resources = _cyclicOperationsService.GetCyclicOperations(query, UserId);
     Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(resources.PagingData()));
     return(resources);
 });
Exemple #2
0
 public PagedList <CyclicOperationResponse> GetCyclicOperations(CyclicOperationGetRequest response, Guid userId)
 => PagedList <CyclicOperationResponse> .ToPagedList(_repository.GetAll()
                                                     .Where(o => o.OperationCategory.UserId == userId)
                                                     .Where(o => o.ResourceId == (response.ResourceId ?? o.ResourceId))
                                                     .Where(o => o.OperationCategoryId == (response.OperationCategoryId ?? o.OperationCategoryId))
                                                     .Where(o => o.IsIncome == (response.IsIncome ?? o.IsIncome))
                                                     .Where(o => o.Name == (response.Name ?? o.Name))
                                                     .Where(o => o.EstimatedValue >= (response.MinEstimatedValue ?? o.EstimatedValue))
                                                     .Where(o => o.EstimatedValue <= (response.MaxEstimatedValue ?? o.EstimatedValue))
                                                     .Where(o => o.Period >= (response.MinPeriod ?? o.Period))
                                                     .Where(o => o.Period <= (response.MaxPeriod ?? o.Period))
                                                     .Where(o => o.NextOccurence >= (response.MinNextOccurence ?? o.NextOccurence))
                                                     .Where(o => o.NextOccurence <= (response.MaxNextOccurence ?? o.NextOccurence))
                                                     .OrderByDescending(o => o.NextOccurence)
                                                     .Select(r => _mapper.Map <CyclicOperationResponse>(r)),
                                                     response.Page, response.Limit);