public async Task <IEnumerable <AlbumAndPhoto> > GetAlbumsAndPhotosAsync() { IEnumerable <AlbumAndPhoto> albumsAndPhotosAggregated = new List <AlbumAndPhoto>(); IEnumerable <Album> albums = await _albumsService.GetAlbumsAsync(); if (albums == null || !albums.Any()) { return(albumsAndPhotosAggregated); } IEnumerable <Photo> photos = await _photosService.GetPhotosAsync(); if (photos == null || !photos.Any()) { return(albumsAndPhotosAggregated); } albumsAndPhotosAggregated = _albumsAndPhotosHelper.GetAggregatedAlbumsAndPhotosResult(albums, photos); return(albumsAndPhotosAggregated); }
public async Task <IActionResult> GetAlbums([FromQuery] PagingOptions pagingOptions, CancellationToken cancellationToken) { if (!ModelState.IsValid) { return(BadRequest(new ApiError() { Message = "Invalid arguments provided.", Details = ModelState.FirstOrDefault(k => k.Value.Errors.Any()).Value.Errors.FirstOrDefault().ErrorMessage })); } pagingOptions.Limit = pagingOptions.Limit ?? _defaultPagingOptions.Limit; pagingOptions.Offset = pagingOptions.Offset ?? _defaultPagingOptions.Offset; var albums = await _albumsService.GetAlbumsAsync(pagingOptions, cancellationToken); var link = Link.CreateCollection(nameof(GetAlbums)); var collection = PagedCollection <AlbumResource> .CreatePagedCollection(link, albums.Items, albums.TotalSize, pagingOptions); return(Ok(collection)); }
public async Task <IActionResult> Get() { var albums = await _albumService.GetAlbumsAsync(); return(Ok(albums)); }
public JsonResult Get() { var ret = _albumsService.GetAlbumsAsync(); return(Json(ret.Result)); }