public ActionResult <InvestigationPersonDto> Update([FromRoute] int id, [FromBody] InvestigationPersonDto personDto) { try { var person = new InvestigationPersonMapper().ToModel(personDto); person.InvestigationPersonId ??= id; var result = _unitOfWork.InvestigationPersons.Update(id, person); _unitOfWork.Save(); return(Ok(new InvestigationPersonMapper().ToDto(result))); } catch (Exception e) { throw new HttpRequestException(e.Message, e, HttpStatusCode.InternalServerError); } }
public ActionResult <PersonDto> Create([FromBody] InvestigationPersonDto personDto) { try { if (personDto is null) { return(BadRequest("Person can't be null")); } var person = new InvestigationPersonMapper().ToModel(personDto); var send = _unitOfWork.InvestigationPersons.Add(person); _unitOfWork.Save(); var dto = new InvestigationPersonMapper().ToDto(send); return(CreatedAtAction(nameof(Get), new { id = dto.InvestigationPersonId }, dto)); } catch (Exception e) { throw new HttpRequestException(e.Message, e, HttpStatusCode.InternalServerError); } }