예제 #1
0
        public GetHighlightsResponse GetHighlightsForGrid(GetHighlightsRequest 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 GetHighlightsResponse
            {
                TotalRecords = totalRecords,
                Highlights = data.ToList().MapTo<GetHighlightsResponse.HighlightResponse>()
            };
        }
예제 #2
0
 public GetHighlightsResponse GetHighlights(GetHighlightsRequest request)
 {
     if (request.OnlyCount)
     {
         var query = DataContext.Highlights.Include(x => x.HighlightType).AsQueryable();
         if (request.PeriodeType != null)
         {
             query = query.Where(x => x.PeriodeType == request.PeriodeType);
         }
         return new GetHighlightsResponse { Count = query.Count() };
     }
     else if (request.Except.Length > 0 && request.Date.HasValue)
     {
         return new GetHighlightsResponse
         {
             Highlights = DataContext.Highlights.Include(x => x.HighlightType).Where(x => x.Date == request.Date.Value && !request.Except.Contains(x.HighlightType.Value) && x.IsActive == request.IsActive)
             .ToList().MapTo<GetHighlightsResponse.HighlightResponse>()
         };
     }
     else if (request.Include.Length > 0 && request.Date.HasValue)
     {
         return new GetHighlightsResponse
         {
             Highlights = DataContext.Highlights.Include(x => x.HighlightType).Where(x => x.Date == request.Date.Value && request.Include.Contains(x.HighlightType.Value) && x.IsActive == request.IsActive)
             .ToList().MapTo<GetHighlightsResponse.HighlightResponse>()
         };
     }
     else
     {
         var query = DataContext.Highlights.Include(x => x.HighlightType).AsQueryable();
         if (request.PeriodeType == request.PeriodeType) // WTF????
         {
             query = query.Where(x => x.PeriodeType == request.PeriodeType);
         }
         return new GetHighlightsResponse
         {
             Highlights = query.OrderByDescending(x => x.Id).Skip(request.Skip).Take(request.Take)
                             .ToList().MapTo<GetHighlightsResponse.HighlightResponse>()
         };
     }
 }