コード例 #1
0
        public async Task <IActionResult> Index()
        {
            var user = await _userManager.GetUserAsync(HttpContext.User);

            FavoriteViewModel viewModel = new FavoriteViewModel();
            List <Photo>      favorites = await _repository.GetFavoritePhotos(user.Id);

            foreach (Photo photo in favorites)
            {
                if (photo == null)
                {
                    continue;
                }
                User owner = await _repository.GetUserId(photo.Id);

                viewModel.Photos.Add(new PhotoFavViewModel(photo, owner));
            }
            return(View(viewModel));
        }