Пример #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));
            }
        }
Пример #2
0
        public async Task <Result <AddPersonEducationalLevelResponse> > Handle(PersonEducationLevelCommand request, CancellationToken cancellationToken)
        {
            try {
                RegisterPersonService rs = new RegisterPersonService(_unitOfWork);
                if (request.PersonId > 0)
                {
                    PersonEducation pme = new PersonEducation();
                    pme = await rs.GetCurrentPersonEducation(request.PersonId);

                    if (pme != null)
                    {
                        pme.EducationLevel = request.EducationalLevel;
                        pme.CreatedBy      = request.UserId;
                        await rs.UpdatePersonEducation(pme);

                        msg += "Person Educatin updated successfully";
                    }
                    else
                    {
                        PersonEducation ped = new PersonEducation();
                        ped.PersonId       = request.PersonId;
                        ped.CreatedBy      = request.UserId;
                        ped.EducationLevel = request.EducationalLevel;
                        ped.CreateDate     = DateTime.Now;
                        var peducation = await rs.AddPersonEducation(ped);

                        if (peducation != null)
                        {
                            msg = "PersonEducationalLevel added successfully for personId" + request.PersonId;
                        }
                    }
                }


                return(Result <AddPersonEducationalLevelResponse> .Valid(new AddPersonEducationalLevelResponse()
                {
                    Message = msg
                }));
            }

            catch (Exception e) {
                return(Result <AddPersonEducationalLevelResponse> .Invalid(e.Message));
            }
        }