public async Task <ArtistResponse> Get(int id) { var artist = await _artistCollection.GetArtistByIdAsync(id); if (artist == null) { throw new HttpException(HttpStatusCode.NotFound); } return(await ArtistResponse.CreateFromArtistAsync(artist)); }
public async Task <ArtistResponse> Create([FromBody] CreateArtistRequest request) { var user = await _authenticatedUser.GetUserAsync(); var artist = await user.GetArtistAsync(); if (artist != null) { throw new HttpException(HttpStatusCode.Unauthorized); } var result = await _artistCollection.CreateArtistAsync(user.Id, request.Name); if (result == null) { throw new HttpException(HttpStatusCode.InternalServerError); } return(await ArtistResponse.CreateFromArtistAsync(result)); }