public async Task <Result <AddPatientOVCStatusResponse> > Handle(AddPatientOVCStatusCommand request, CancellationToken cancellationToken) { try { using (_unitOfWork) { int Id = 0; RegisterPersonService registerPersonService = new RegisterPersonService(_unitOfWork); var registeredPatientOVCStatus = await registerPersonService.GetPatientOVCStatusByPersonId(request.PersonId); if (registeredPatientOVCStatus != null) { registeredPatientOVCStatus.Active = request.Active; registeredPatientOVCStatus.CreatedBy = request.CreatedBy; registeredPatientOVCStatus.Deleteflag = request.Deleteflag; registeredPatientOVCStatus.InSchool = request.InSchool; } else { PatientOVCStatus po = new PatientOVCStatus(); po.PersonId = request.PersonId; po.InSchool = request.InSchool; po.Orphan = request.Orphan; po.Active = request.Active; po.Deleteflag = request.Deleteflag; po.CreatedBy = request.CreatedBy; po.CreateDate = DateTime.Now; po.GuardianId = 0; var patientovcstatus = await registerPersonService.AddPatientOVCStatus(po); Id = patientovcstatus.Id; } return(Result <AddPatientOVCStatusResponse> .Valid(new AddPatientOVCStatusResponse() { OVCStatusId = Id })); } } catch (Exception ex) { return(Result <AddPatientOVCStatusResponse> .Invalid(ex.Message)); } }
public async Task <Result <PatientOVCStatus> > Handle(GetPatientOVCStatusCommand request, CancellationToken cancellationToken) { using (_unitOfWork) { try { RegisterPersonService rs = new RegisterPersonService(_unitOfWork); var PatientOVCStatus = await rs.GetPatientOVCStatusByPersonId(request.PersonId); return(Result <PatientOVCStatus> .Valid(PatientOVCStatus)); } catch (Exception ex) { return(Result <PatientOVCStatus> .Invalid(ex.Message)); } } }