public async Task <ActionResult <PersonDto> > UpdatePerson(int id, [FromBody] PersonFormModel personForm) { try { if (null == personForm) { throw new ArgumentNullException(nameof(personForm), "Person data is invalid."); } var updatedResult = await _mediator.Send(new UpdatePersonRequest(id, personForm)); return(NoContent()); } catch (ArgumentNullException argNullException) { return(BadRequest(argNullException.Message)); } catch (NullReferenceException nullRefException) { return(NotFound(nullRefException.Message)); } }
public async Task <ActionResult <PersonDto> > CreatePerson([FromBody] PersonFormModel personForm) { try { if (null == personForm) { throw new ArgumentNullException(nameof(personForm), "Person data is invalid."); } var createdResult = await _mediator.Send(new CreatePersonRequest(personForm)); return(CreatedAtAction(nameof(this.GetPerson), new { id = createdResult.Id }, createdResult)); } catch (ArgumentNullException argNullException) { return(BadRequest(argNullException.Message)); } catch (NullReferenceException nullRefException) { return(NotFound(nullRefException.Message)); } }
public CreatePersonRequest(PersonFormModel personForm) { PersonForm = personForm; }
public UpdatePersonRequest(int id, PersonFormModel personForm) { Id = id; PersonForm = personForm; }
public ActionResult Index(PersonFormModel personFormModel) { ViewBag.Fname = personFormModel.Fname; return(View(personFormModel)); }