public async Task <object> AddPartnerTesting([FromBody] PatientPartnerTestingCommand command) { if (!ModelState.IsValid) { return(BadRequest(command)); } var result = await _mediator.Send(command, HttpContext.RequestAborted); if (result.IsValid) { return(Ok(result.Value)); } return(BadRequest(result)); }
public async Task <Result <PatientPatnerTestingResponse> > Handle(PatientPartnerTestingCommand request, CancellationToken cancellationToken) { try { var patientPatnerTesting = _mapper.Map <PatientPartnerTesting>(request); await _maternityUnitOfWork.Repository <PatientPartnerTesting>().AddAsync(patientPatnerTesting); await _maternityUnitOfWork.SaveAsync(); return(Result <PatientPatnerTestingResponse> .Valid(new PatientPatnerTestingResponse { PatientId = patientPatnerTesting.Id })); } catch (Exception ex) { logger.Error(ex, $"An error occured while adding patient patner testing info {request.PatientMasterVisitId}"); return(Result <PatientPatnerTestingResponse> .Invalid(ex.Message)); } }