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 InvestigationPerson Map(InvestigationPersonDto person) { return(new() { InvestigationPersonId = person.InvestigationPersonId, FirstName = person.FirstName, LastName = person.LastName, Email = person.Email, PhoneNumber = person.PhoneNumber, Address = person.Address, ZipCode = person.ZipCode, City = person.City, Type = person.Type }); }
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); } }
public async Task <InvestigationPersonDto> UpdateInvestigationPersonAsync(int id, InvestigationPersonDto investigationPerson) { return(await new HttpRequestService <InvestigationPersonDto>().UpdateAsync(id, investigationPerson, _investigation, Api)); }