Beispiel #1
0
 public GetEconomicSummariesResponse GetEconomicSummaries(GetEconomicSummariesRequest request)
 {
     if (request.OnlyCount)
     {
         var query = DataContext.EconomicSummaries.AsQueryable();
         if (!string.IsNullOrEmpty(request.Term))
         {
             query = query.Where(x => x.Name.ToLower().Contains(request.Term.ToLower()));
         }
         return new GetEconomicSummariesResponse { Count = query.Count() };
     }
     else
     {
         var query = DataContext.EconomicSummaries.AsQueryable();
         if (!string.IsNullOrEmpty(request.Term))
         {
             query = query.Where(x => x.Name.ToLower().Contains(request.Term.ToLower()));
         }
         query = query.OrderByDescending(x => x.Id);
         if (request.Skip != 0)
         {
             query = query.Skip(request.Skip);
         }
         if (request.Take != 0)
         {
             query = query.Take(request.Take);
         }
         return new GetEconomicSummariesResponse
         {
             EconomicSummaries = query.ToList()
                 .MapTo<GetEconomicSummariesResponse.EconomicSummary>()
         };
     }
 }
Beispiel #2
0
        public GetEconomicSummariesResponse GetEconomicSummariesForGrid(GetEconomicSummariesRequest request)
        {
            int totalRecords;
            var data = SortData(request.Search, request.SortingDictionary, out totalRecords);
            if (request.Take != -1)
            {
                data = data.Skip(request.Skip).Take(request.Take);
            }

            return new GetEconomicSummariesResponse
            {
                TotalRecords = totalRecords,
                EconomicSummaries = data.ToList().MapTo<GetEconomicSummariesResponse.EconomicSummary>()
            };
        }