Exemplo n.º 1
0
 public GetHighlightResponse GetHighlight(GetHighlightRequest request)
 {
     if (request.Id != 0)
     {
         return(DataContext.Highlights.Include(x => x.HighlightType).FirstOrDefault(x => x.Id == request.Id).MapTo <GetHighlightResponse>());
     }
     else
     {
         var highlightQuery = DataContext.Highlights.Include(x => x.HighlightType);
         if (request.Date.HasValue)
         {
             highlightQuery = highlightQuery.Where(x => x.Date == request.Date && x.HighlightType.Value == request.Type);
         }
         else
         {
             highlightQuery = highlightQuery.OrderByDescending(x => x.Date).Where(x => x.HighlightType.Value == request.Type);
         }
         var highlight = highlightQuery.FirstOrDefault();
         if (highlight != null)
         {
             return(highlight.MapTo <GetHighlightResponse>());
         }
         return(new GetHighlightResponse());
     }
 }
Exemplo n.º 2
0
        public GetHighlightResponse GetHighlightByPeriode(GetHighlightRequest request)
        {
            var data = DataContext.Highlights
                       .Include(x => x.HighlightType)
                       .Where(x => x.PeriodeType == PeriodeType.Daily)
                       .Where(x => x.Date == request.Date)
                       .AsQueryable();

            if (request.HighlightTypeId > 0)
            {
                data = data.Where(x => x.HighlightType.Id == request.HighlightTypeId);
            }

            if (!string.IsNullOrEmpty(request.Type))
            {
                data = data.Where(x => x.Type == request.Type);
            }

            var result = data.FirstOrDefault();

            if (result != null)
            {
                return(result.MapTo <GetHighlightResponse>());
            }

            return(new GetHighlightResponse());
        }
Exemplo n.º 3
0
        public GetHighlightResponse GetHighlightByPeriode(GetHighlightRequest request, bool latest = false)
        {
            var data = DataContext.Highlights
                       .Include(x => x.HighlightType)
                       .Where(x => x.PeriodeType == (request.PeriodeType.HasValue? request.PeriodeType : PeriodeType.Daily))
                       .AsQueryable();

            if (latest)
            {
                data = data.OrderByDescending(x => x.Date);
            }
            else
            {
                data = data.Where(x => x.Date == request.Date);
            }


            if (request.HighlightTypeId > 0)
            {
                data = data.Where(x => x.HighlightType.Id == request.HighlightTypeId);
            }

            if (!string.IsNullOrEmpty(request.Type))
            {
                data = data.Where(x => x.Type == request.Type);
            }

            var result = data.FirstOrDefault();

            if (result != null)
            {
                return(result.MapTo <GetHighlightResponse>());
            }

            return(new GetHighlightResponse());
        }