public async Task <Result <PersonMaritalStatus> > Handle(UpdatePersonMaritalStatusCommand request, CancellationToken cancellationToken) { using (_unitOfWork) { try { PersonMaritalStatus personMaritalStatus = new PersonMaritalStatus(); RegisterPersonService registerPersonService = new RegisterPersonService(_unitOfWork); var maritalStatusList = await registerPersonService.GetPersonMaritalStatus(request.PersonId); if (maritalStatusList.Count > 0) { personMaritalStatus = await registerPersonService.UpdateMaritalStatus(request.PersonId, request.MaritalStatusId); } else { personMaritalStatus = await registerPersonService.AddMaritalStatus(request.PersonId, request.MaritalStatusId, request.UserId); } return(Result <PersonMaritalStatus> .Valid(personMaritalStatus)); } catch (Exception e) { Log.Error(e.Message); return(Result <PersonMaritalStatus> .Invalid(e.Message)); } } }
public async Task <Result <AddPatientResponse> > Handle(AddPatientCommand request, CancellationToken cancellationToken) { try { using (_unitOfWork) { RegisterPersonService registerPersonService = new RegisterPersonService(_unitOfWork); var registeredPerson = await registerPersonService.GetPerson(request.PersonId); var gender = await _unitOfWork.Repository <LookupItemView>().Get(x => x.ItemId == registeredPerson.Sex && x.MasterName == "Gender") .ToListAsync(); var maritalStatus = await registerPersonService.GetPersonMaritalStatus(request.PersonId); var maritalStatusName = "Single"; if (maritalStatus.Count > 0) { var matList = await _unitOfWork.Repository <LookupItemView>() .Get(x => x.ItemId == maritalStatus[0].MaritalStatusId && x.MasterName == "MaritalStatus").ToListAsync(); if (matList.Count > 0) { maritalStatusName = matList[0].ItemName; } } var mstResult = await registerPersonService.InsertIntoBlueCard(registeredPerson.FirstName, registeredPerson.LastName, registeredPerson.LastName, request.EnrollmentDate, maritalStatusName, "", "", gender[0].ItemName, "EXACT", registeredPerson.DateOfBirth, request.UserId, request.PosId); var patient = await registerPersonService.AddPatient(request.PersonId, request.UserId, mstResult[0].Ptn_Pk); return(Result <AddPatientResponse> .Valid(new AddPatientResponse() { PatientId = patient.Id })); } } catch (Exception e) { return(Result <AddPatientResponse> .Invalid(e.Message)); } }