public async Task <ActionResult <Mode> > PostMode(Mode mode) { try { await _modeService.CreateModeAsync(mode); } catch (ArgumentNullException ex) { return(BadRequest(ex.Message)); } return(CreatedAtAction("GetMode", new { id = mode.Id }, mode)); }
public async Task <IActionResult> OnPost() { if (!ModelState.IsValid) { return(Page()); } try { await _modeService.CreateModeAsync(Mode); } catch (Exception ex) { return(BadRequest(ex)); } return(RedirectToPage("./Modes")); }