예제 #1
0
 public async Task <IEnumerable <BlogPostBase> > GetLatestBlogPosts(AgeRestrictionCategories allowedAges, int limit)
 {
     return(await db.BlogPosts
            .Where(bp => (bp.AllowedAge & allowedAges) == allowedAges)
            .OrderBy(bp => bp.CreatedOn)
            .Take(limit)
            .ToListAsync());
 }
예제 #2
0
        public static IEnumerable <string> GetAgeRestrictions(this AgeRestrictionCategories categories)
        {
            List <string> result = new List <string>();

            foreach (AgeRestrictionCategories r in Enum.GetValues(typeof(AgeRestrictionCategories)))
            {
                if ((categories & r) != 0)
                {
                    result.Add(r.ToString());
                }
            }
            return(result);
        }
예제 #3
0
 public BlogPostBase(AgeRestrictionCategories allowedAges, string category)
 {
     AllowedAge = allowedAges;
     CreatedOn  = DateTime.Now;
     Category   = category;
 }
 public async Task <IEnumerable <BlogPostBase> > GetAllBlogPostsByAgeRestriction(AgeRestrictionCategories allowedAges, BlogPostFilter filter = null)
 {
     return(await Task.FromResult(ApplyFilters(blogPosts, filter).Where(b => (b.AllowedAge & allowedAges) == allowedAges).ToList()));
 }
예제 #5
0
 public async Task <IEnumerable <BlogPostBase> > GetAllBlogPostsByAgeRestriction(AgeRestrictionCategories allowedAge, BlogPostFilter filter = null)
 {
     return(await ApplyFilters(db.BlogPosts, filter).Where(bp => (bp.AllowedAge & allowedAge) == allowedAge).ToListAsync());
 }