Example #1
0
        public async Task <Result <GetPersonDetailsResponse> > Handle(GetPersonDetailsCommand request, CancellationToken cancellationToken)
        {
            try
            {
                RegisterPersonService rs = new RegisterPersonService(_unitOfWork);
                int id = request.PersonId;
                if (request.PersonId > 0)
                {
                    persondetail = await rs.GetPerson(id);

                    personEducation = await rs.GetCurrentPersonEducation(id);

                    personocc = await rs.GetCurrentOccupation(id);

                    personmarital = await rs.GetFirstPatientMaritalStatus(id);

                    personlocation = await rs.GetCurrentPersonLocation(id);

                    personcontact = await rs.GetCurrentPersonContact(id);

                    personemerg = await rs.GetCurrentPersonEmergency(id);

                    pid = await rs.GetCurrentPersonIdentifier(id);

                    pt = await rs.GetPatientByPersonId(id);
                }


                _unitOfWork.Dispose();


                return(Result <GetPersonDetailsResponse> .Valid(new GetPersonDetailsResponse()
                {
                    personDetail = persondetail,
                    personEducation = personEducation,
                    personOccupation = personocc,
                    personMaritalStatus = personmarital,
                    personLocation = personlocation,
                    personContact = personcontact,
                    PersonEmergencyView = personemerg,
                    personIdentifier = pid,
                    patient = pt
                }));
            }
            catch (Exception ex)
            {
                return(Result <GetPersonDetailsResponse> .Invalid(ex.Message));
            }
        }
        public async Task <Result <AddUpdatePersonLocationResponse> > Handle(AddUpdatePersonLocationCommand request, CancellationToken cancellationToken)
        {
            try
            {
                RegisterPersonService rs = new RegisterPersonService(_unitOfWork);
                if (request.PersonId > 0)
                {
                    var currentlocation = await rs.GetCurrentPersonLocation(request.PersonId);

                    if (currentlocation != null)
                    {
                        currentlocation.PersonId            = request.PersonId;
                        currentlocation.County              = request.CountyId;
                        currentlocation.SubCounty           = request.SubCountyId;
                        currentlocation.Ward                = request.WardId;
                        currentlocation.LandMark            = request.LandMark;
                        currentlocation.NearestHealthCentre = request.NearestHealthCentre;
                        currentlocation.CreatedBy           = request.UserId;

                        res = await rs.UpdatePersonLocation(currentlocation);

                        if (res > 0)
                        {
                            msg += "Person Location Successfully Updated";
                        }
                    }
                    else
                    {
                        res = await Task.Run(() => rs.AddPersonLocation(request.PersonId, request.CountyId, request.SubCountyId, request.WardId, "", "", "", request.LandMark, request.NearestHealthCentre, request.UserId));

                        if (res > 0)
                        {
                            msg += "Person Location Successfully Added";
                        }
                    }
                }
                return(Result <AddUpdatePersonLocationResponse> .Valid(new AddUpdatePersonLocationResponse()
                {
                    Message = msg
                }
                                                                       ));
            }
            catch (Exception e)
            {
                return(Result <AddUpdatePersonLocationResponse> .Invalid(e.Message));
            }
        }