Exemplo n.º 1
0
        public async Task <ActionResult <ArtistResponse> > PostArtist(ArtistPostRequest request)
        {
            var artist = _mapper.Map <Artist>(request);
            await _repository.Create(artist);

            return(Ok(artist.ArtistId));
        }
Exemplo n.º 2
0
        public async Task <ActionResult <ArtistGetResponse> > CreateArtist([FromBody] ArtistPostRequest artistPostRequest)
        {
            var artistEntity = _mapper.Map <Artist>(artistPostRequest);

            artistEntity.Id = Guid.NewGuid();

            _artistRepository.AddArtist(artistEntity);
            await _artistRepository.SaveAsync();

            var artistGetResponse = _mapper.Map <ArtistGetResponse>(artistEntity);

            return(CreatedAtRoute(
                       "GetArtist",
                       new
            {
                version = HttpContext.GetRequestedApiVersion().ToString(),
                artistId = artistGetResponse.Id
            },
                       artistGetResponse));
        }