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

            var          modelUser = _repository.GetUser(user.Id);
            List <Album> albums    = await _repository.GetMyAlbumsAsync(user.Id);

            Models.AlbumViewModels.IndexViewModel model = new IndexViewModel();
            foreach (Album album in albums)
            {
                AlbumViewModel viewModel = new AlbumViewModel(album.Id, album.DateCreated, modelUser, album.Name);
                List <Photo>   photos    = await _repository.GetPhotosAsync(album.Id);

                if (photos.Count > 0)
                {
                    viewModel.ThumbnailImage = photos.First().ThumbnailImage;
                }
                model.Albums.Add(viewModel);
            }

            return(View(model));
        }