Esempio n. 1
0
 public int Total(string search, bool?confirmed, int astronomerId, AstronomerType astronomerType)
 {
     return(this.db
            .Discoveries
            .Filter(search)
            .Confirmed(confirmed)
            .ByAstronomerType(astronomerId, astronomerType)
            .Count());
 }
Esempio n. 2
0
 public IEnumerable <ListDiscoveriesServiceModel> All(
     int page,
     int pageSize,
     string search,
     bool?confirmed,
     int astronomerId,
     AstronomerType astronomerType)
 {
     return(this.db
            .Discoveries
            .OrderByDescending(d => d.DateMade)
            .Filter(search)
            .Confirmed(confirmed)
            .ByAstronomerType(astronomerId, astronomerType)
            .Skip((page - 1) * pageSize)
            .Take(pageSize)
            .ProjectTo <ListDiscoveriesServiceModel>()
            .ToList());
 }
Esempio n. 3
0
        public static IQueryable <Discovery> ByAstronomerType(this IQueryable <Discovery> discoveries, int astronomerId, AstronomerType astronomerType)
        {
            if (astronomerType == AstronomerType.All)
            {
                return(discoveries
                       .Where(d => d.Pioneers.Any(p => p.PioneerId == astronomerId) ||
                              d.Observers.Any(o => o.ObserverId == astronomerId)));
            }
            else if (astronomerType == AstronomerType.Pioneer)
            {
                return(discoveries
                       .Where(d => d.Pioneers.Any(p => p.PioneerId == astronomerId)));
            }
            else if (astronomerType == AstronomerType.Observer)
            {
                return(discoveries
                       .Where(d => d.Observers.Any(o => o.ObserverId == astronomerId)));
            }

            return(discoveries);
        }