/// <inheritdoc /> public async Task <MementoResponse> UpdateAsync(long genreId, GenreFormContract genre) { // Invoke the API var response = await this.HttpService.PutAsync($"{API_URL}{genreId}", genre); if (!response.Success) { throw new ApplicationException(string.Join(Environment.NewLine, response.Errors)); } else { return(response); } }
/// <inheritdoc /> public async Task <MementoResponse <GenreDetailContract> > CreateAsync(GenreFormContract genre) { // Invoke the API var response = await this.HttpService.PostAsync <GenreFormContract, GenreDetailContract>($"{API_URL}", genre); if (!response.Success) { throw new ApplicationException(string.Join(Environment.NewLine, response.Errors)); } else { return(response); } }
public async Task <ActionResult <MementoResponse> > UpdateAsync([FromRoute] long id, [FromBody] GenreFormContract contract) { // Map the genre var genre = this.Mapper.Map <Genre>(contract); genre.Id = id; // Update the genre await this.Repository.UpdateAsync(genre); // Build the response return(this.BuildUpdateResponse()); }
public async Task <ActionResult <MementoResponse <GenreDetailContract> > > CreateAsync([FromBody] GenreFormContract contract) { // Map the genre var genre = this.Mapper.Map <Genre>(contract); // Create the genre var createdGenre = await this.Repository.CreateAsync(genre); // Build the response return(this.BuildCreateResponse <Genre, GenreDetailContract>(createdGenre)); }