public async Task <IActionResult> Post([FromBody] HEIDeliveryCommand heiDeliveryCommand) { var response = await _mediator.Send(heiDeliveryCommand, Request.HttpContext.RequestAborted); if (response.IsValid) { return(Ok(response.Value)); } return(BadRequest(response)); }
public async Task <Result <AddHeiDeliveryCommandResponse> > Handle(HEIDeliveryCommand request, CancellationToken cancellationToken) { using (_unitOfWork) { try { HEIEncounterService heiEncounterService = new HEIEncounterService(_unitOfWork); HEIEncounter heiEncounter = new HEIEncounter() { PatientId = request.PatientId, PatientMasterVisitId = request.PatientMasterVisitId, PlaceOfDeliveryId = request.PlaceOfDelivery, ModeOfDeliveryId = request.ModeOfDelivery, BirthWeight = request.BirthWeight, ArvProphylaxisId = request.ProphylaxisReceived, ArvProphylaxisOther = request.ProphylaxisReceivedOther, MotherRegisteredId = request.MotherIsRegistered, MotherPersonId = request.MotherPersonId, MotherStatusId = request.MotherStatusId, PrimaryCareGiverID = request.PrimaryCareGiverID, MotherName = request.MotherName, MotherCCCNumber = request.MotherCCCNumber, MotherPMTCTDrugsId = request.MotherPMTCTDrugsId, MotherPMTCTRegimenId = request.MotherPMTCTRegimenId, MotherPMTCTRegimenOther = request.MotherPMTCTRegimenOther, MotherArtInfantEnrolId = request.MotherArtInfantEnrolId, MotherArtInfantEnrolRegimenId = request.MotherArtInfantEnrolRegimenId, DeleteFlag = false, CreateDate = DateTime.Now, CreatedBy = request.CreatedBy, }; HEIEncounter heiEncounterResult = await heiEncounterService.AddHeiEncounter(heiEncounter); return(Result <AddHeiDeliveryCommandResponse> .Valid(new AddHeiDeliveryCommandResponse() { HeiEncounterId = heiEncounterResult.Id })); } catch (Exception e) { Log.Error(e.Message + " " + e.InnerException); return(Result <AddHeiDeliveryCommandResponse> .Invalid(e.Message)); } } }