示例#1
0
        public async Task <IActionResult> Album()
        {
            var userId     = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            var imageCount = await this.imageService.GetImageCountOfCurrentUser(userId);

            var pictures = await this.modelService.TakeAllPictures <AlbumViewModel>(userId);

            var viewModel = new AlbumBindingViewModel
            {
                AlbumViewModel = pictures,
                ImageCount     = imageCount,
            };

            return(this.View(viewModel));
        }
示例#2
0
        public async Task <IActionResult> Album(AlbumBindingViewModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

            var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);

            var imageUrls = input.AlbumInputViewModel.UserImages
                            .Select(async x =>
                                    await this.cloudinaryService.UploadPictureAsync(x, x.FileName))
                            .Select(x => x.Result)
                            .ToList();

            await this.modelService.UploadAlbum(imageUrls, userId);

            return(this.RedirectToAction(nameof(this.MyProfile)));
        }