public async Task <IActionResult> CreateArtist([FromBody] ArtistCreateRequest artistCreateRequest) { var artistEntity = _mapper.Map <Artist>(artistCreateRequest); artistEntity.Id = Guid.NewGuid().ToString(); _artistRepo.CreateArtist(artistEntity); await _artistRepo.SaveAsync(); return(Json(new { data = artistEntity, message = "Success" })); }
public async Task <IActionResult> CreateArtist([FromBody] ArtistCreateRequest postRequest) { try { var post = _mapper.Map <ArtistModel>(postRequest); bool exists = await _artistService.ArtistNameExistsAsync(post); if (exists) { return(BadRequest(new ErrorResponse(ErrorMessages.Artist.NameExists))); } var artist = await _artistService.CreateArtistAsync(post); var locationUri = ApiRoutes.Artists.Route + "/" + artist.ArtistId; return(Created(locationUri, new Response <ArtistResponse>(_mapper.Map <ArtistResponse>(artist)))); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, new ErrorResponse(ErrorMessages.Artist.FailedCreate))); } }
public async Task <ActionResult <ArtistGetResponse> > CreateArtistA([FromBody] ArtistCreateRequest artistCreateRequest) { return(Ok()); }