Ejemplo n.º 1
0
        public async Task <IActionResult> Get(string userId, int pageSize, int pageIndex)
        {
            var albums = await _albumRepository.GetAlbumsAsync(userId, pageSize, pageIndex);

            var totalAlbums = await _albumRepository.GetTotalAlbumsAsync(userId);

            _logger.LogInformation($"Albums for userId={userId} were successfully received, pageSize={pageSize}, pageIndex={pageIndex}.");

            return(Ok(new { albums, totalAlbums }));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Get(string userId, int pageSize, int pageIndex)
        {
            var photos = await _photoRepository.GetPhotosByUserIdAsync(userId, pageSize, pageIndex);

            foreach (var photo in photos)
            {
                photo.Albums = await _albumRepository.GetAlbumsAsync(photo.PhotoId);
            }

            var totalPhotos = await _photoRepository.GetTotalPhotosByUserIdAsync(userId);

            _logger.LogInformation($"Photos for userId={userId} was successfully received, pageSize={pageSize}, pageIndex={pageIndex}.");

            return(Ok(new { photos, totalPhotos }));
        }
        public async Task <IActionResult> Get(string photoId)
        {
            var photo = await _photoRepository.GetPhotoAsync(photoId);

            if (photo == null)
            {
                _logger.LogWarning($"Photo with photoId={photoId} was not found.");
                return(NotFound());
            }

            photo.Albums = await _albumRepository.GetAlbumsAsync(photoId);

            _logger.LogInformation($"Photo with photoId={photoId} was successfully received.");

            return(Ok(photo));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Get(string albumId, int pageSize, int pageIndex)
        {
            var album = await _albumRepository.GetAlbumAsync(albumId);

            if (album == null)
            {
                _logger.LogWarning($"Album with albumId={albumId} was not found.");
                return(NotFound());
            }

            var photos = await _photoRepository.GetPhotosByAlbumIdAsync(albumId, pageSize, pageIndex);

            foreach (var photo in photos)
            {
                photo.Albums = await _albumRepository.GetAlbumsAsync(photo.PhotoId);
            }

            var totalPhotos = await _photoRepository.GetTotalPhotosByAlbumIdAsync(albumId);

            _logger.LogInformation($"Album with albumId={albumId} was successfully received with photos, pageSize={pageSize}, pageIndex={pageIndex}.");

            return(Ok(new { album, photos, totalPhotos }));
        }