예제 #1
0
 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);
     }
 }
예제 #2
0
 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
     });
 }
예제 #3
0
 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);
     }
 }
예제 #4
0
 public async Task <InvestigationPersonDto> UpdateInvestigationPersonAsync(int id, InvestigationPersonDto investigationPerson)
 {
     return(await new HttpRequestService <InvestigationPersonDto>().UpdateAsync(id, investigationPerson, _investigation, Api));
 }