コード例 #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;
 }
コード例 #4
0
 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());
 }