public async Task <IHttpActionResult> PutAsync(string genreName, [FromBody] GenreCompleteModelIn newGenre) { await Task.Yield(); if (genreName == "" || newGenre == null) { return(BadRequest("Genre name can not be empty")); } try { genreService.Update(genreName, newGenre.ToEntity()); return(Ok(newGenre)); } catch (DataBaseException) { return(Content(HttpStatusCode.NotFound, $"{genreName} does not exist in our database")); } }
public async Task <IHttpActionResult> PostAsync([FromBody] GenreCompleteModelIn newGenre) { await Task.Yield(); if (newGenre == null) { return(BadRequest("Genre can not be empty")); } try { genreService.Upload(newGenre.ToEntity()); return(Content(HttpStatusCode.Created, $"{newGenre.Name} created")); } catch (DataBaseException) { return(Content(HttpStatusCode.Accepted, $"{newGenre.Name} already exists")); } }