Esempio n. 1
0
        public async Task <bool> Post(int id)
        {
            var user = await _authenticatedUser.GetUserAsync();

            var song = await _songCollection.GetSongByIdAsync(id);

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

            return(await song.LikeAsync(user.Id));
        }
Esempio n. 2
0
        public async Task <bool> UpdateName(int id, [FromBody] UpdateSongRequest request)
        {
            var artist = await _authenticatedUser.GetArtistAsync();

            var song = await _songCollection.GetSongByIdAsync(id);

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

            song.Name     = request.Name;
            song.Duration = request.Durtion;

            return(await song.SaveAsync());
        }