public async Task <ActionResult <Genre> > PostGenre(Genre genre) { try { await _genreService.CreateGenreAsync(genre); } catch (ArgumentNullException ex) { return(BadRequest(ex.Message)); } return(CreatedAtAction("GetGenre", new { id = genre.Id }, genre)); }
public async Task <IActionResult> OnPost() { if (!ModelState.IsValid) { return(Page()); } try { await _genreService.CreateGenreAsync(Genre); } catch (Exception ex) { return(BadRequest(ex)); } return(RedirectToPage("./Genres")); }