public async Task <ActionResult> Create(InputModel model) { try { await _repository.Add(new Reader(model.EmailAddress, model.Username, model.Name)); return(StatusCode(StatusCodes.Status201Created)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex)); } }
public async Task <ActionResult> Create(ReaderInputModel model) { try { if (!ModelState.IsValid) { return(View("~/Views/Readers/CreateOrUpdate.cshtml", model)); } await _repository.Add(model); return(RedirectToAction(nameof(Index))); } catch { return(View("~/Views/Readers/CreateOrUpdate.cshtml", model)); } }