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()); }
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); }
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())); }
public async Task <IEnumerable <BlogPostBase> > GetAllBlogPostsByAgeRestriction(AgeRestrictionCategories allowedAge, BlogPostFilter filter = null) { return(await ApplyFilters(db.BlogPosts, filter).Where(bp => (bp.AllowedAge & allowedAge) == allowedAge).ToListAsync()); }