public ActionResult <InvestigationDto> UpdateInvestigation([FromRoute] int id, [FromBody] InvestigationDto investigationDto) { try { var investigation = new InvestigationMapper().ToModel(investigationDto); investigation.InvestigationId ??= id; var result = _unitOfWork.Investigations.Update(id, investigation); _unitOfWork.Save(); return(Ok(new InvestigationMapper().ToDto(result))); } catch (Exception e) { throw new HttpRequestException(e.Message, e, HttpStatusCode.InternalServerError); } }
public ActionResult <InvestigationDto> CreateInvestigation([FromBody] InvestigationDto investigationDto) { try { if (investigationDto is null) { return(BadRequest("Investigation can't be null")); } var investigation = new InvestigationMapper().ToModel(investigationDto); var send = _unitOfWork.Investigations.Add(investigation); _unitOfWork.Save(); var dto = new InvestigationMapper().ToDto(send); return(CreatedAtAction(nameof(GetInvestigationById), new { id = dto.InvestigationId }, dto)); } catch (Exception e) { throw new HttpRequestException(e.Message, e, HttpStatusCode.InternalServerError); } }