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())); }
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)); }