Ejemplo n.º 1
0
        public async Task <AlbumResponse> Get(int id)
        {
            var album = await _albumCollection.GetAlbumByIdAsync(id);

            if (album == null)
            {
                throw new HttpException(HttpStatusCode.NotFound);
            }

            return(await AlbumResponse.CreateFromAlbumAsync(album));
        }
Ejemplo n.º 2
0
        public async Task <bool> Post(int id)
        {
            var user = await _authenticatedUser.GetUserAsync();

            var album = await _albumCollection.GetAlbumByIdAsync(id);

            if (album == null)
            {
                throw new HttpException(HttpStatusCode.NotFound);
            }

            return(await album.LikeAsync(user.Id));
        }
Ejemplo n.º 3
0
        public async Task <SongResponse> Create([FromBody] CreateSongRequest request)
        {
            var artist = await _authenticatedUser.GetArtistAsync();

            var album = await _albumCollection.GetAlbumByIdAsync(request.AlbumId);

            if ((await album.GetArtistAsync()).Id != artist.Id)
            {
                throw new HttpException(HttpStatusCode.Unauthorized);
            }

            var song = await album.CreateSongAsync(request.Name, request.Duration);

            if (song == null)
            {
                throw new HttpException(HttpStatusCode.InternalServerError);
            }

            return(await SongResponse.CreateFromSongAsync(song));
        }
Ejemplo n.º 4
0
 public Task <IAlbum> GetAlbumAsync()
 => _albumCollection.GetAlbumByIdAsync(_albumId);