Exemple #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));
            }
        }
Exemple #2
0
        public async Task <Result <AddPersonOccupationLevelResponse> > Handle(PersonOccupationLevelCommand request, CancellationToken cancellationToken)
        {
            try
            {
                RegisterPersonService sc = new RegisterPersonService(_unitOfWork);
                if (request.PersonId > 0)
                {
                    PersonOccupation pmo = new PersonOccupation();
                    pmo = await Task.Run(() => sc.GetCurrentOccupation(request.PersonId));

                    if (pmo != null)
                    {
                        pmo.DeleteFlag = true;
                        var pm = await Task.Run(() => sc.UpdateOccupation(pmo));

                        // var AddedPersonOcc = await Task.Run(() => sc.AddPersonOccupation(request.PersonId, request.UserId, request.Occupation));
                        if (pm != null)
                        {
                            msg = "PersonOccupation Updated successfully";
                        }
                    }
                    else
                    {
                        var AddedPersonOcc = await Task.Run(() => sc.AddPersonOccupation(request.PersonId, request.UserId, request.Occupation));

                        if (AddedPersonOcc != null)
                        {
                            msg = "PersonOccupation Added  successfully for personId" + request.PersonId;
                        }
                    }
                }
                return(Result <AddPersonOccupationLevelResponse> .Valid(new AddPersonOccupationLevelResponse()
                {
                    Message = msg
                }));
            }
            catch (Exception e)
            {
                return(Result <AddPersonOccupationLevelResponse> .Invalid(e.Message));
            }
        }