Ejemplo n.º 1
0
        public async Task <List <CookBook> > GetUserCookBooksWithEagerLoadedObjectsAsync(ClaimsIdentity identity)
        {
            string currentUserId = new CurrentUserIdRetriever().GetUserId(identity);

            return(EntitySorter.SortCookBooks(await context
                                              .CookBooks
                                              .Where(i => i.OwnerId == currentUserId)
                                              .Include(r => r.Recipes)
                                              .Include(o => o.Owner)
                                              .ToListAsync()));
        }
Ejemplo n.º 2
0
        public ActionResult PublicRecipes()
        {
            string userIdValue = new CurrentUserIdRetriever()
                                 .GetUserId(User.Identity as ClaimsIdentity);
            CookBook cookBook = new CookBook();

            cookBook.Recipes = new EntitySorter()
                               .SortRecipesAndReturn(repository.GetAll()
                                                     .Where(x => x.IsPublic == true && x.OwnerId != userIdValue)
                                                     .ToList())
                               .ToList();
            return(View(cookBook));
        }