public RelationshipTemplate(ClientRelationship relationship)
 {
     Id        = relationship.Id;
     FullName  = relationship.Person.FullName;
     Gender    = relationship.Person.Gender;
     BirthDate = relationship.Person.BirthDate;
 }
Ejemplo n.º 2
0
        public void UpdateRelationShips(string relationshipTypeId, Guid clientId, Guid otherClientId)
        {
            var exisitngRelationship = _clientRelationshipRepository.Find(relationshipTypeId, clientId, otherClientId);

            if (null == exisitngRelationship)
            {
                var newRelation = ClientRelationship.Create(relationshipTypeId, otherClientId, true, clientId, false);
                _clientRelationshipRepository.Save(newRelation);
                var state = RelationshipType.IsPartner(relationshipTypeId)
                    ? LiveState.HtsPatlisted
                    : LiveState.HtsFamlisted;
                _clientStateRepository.SaveOrUpdate(new ClientState(clientId, state));
            }

            var exisitngRelationshipReverse = _clientRelationshipRepository.Find(relationshipTypeId, otherClientId, clientId);

            if (null == exisitngRelationshipReverse)
            {
                //otherClientId  clientId
                var newRelationReverse = ClientRelationship.Create(relationshipTypeId, clientId, true, otherClientId, true);
                _clientRelationshipRepository.Save(newRelationReverse);
                var state = RelationshipType.IsPartner(relationshipTypeId)
                    ? LiveState.PartnerListed
                    : LiveState.FamilyListed;
                _clientStateRepository.SaveOrUpdate(new ClientState(otherClientId, state, clientId));
            }
        }
Ejemplo n.º 3
0
 public PartnerTemplate(ClientRelationship relationship)
 {
     Id              = relationship.Id;
     FullName        = relationship.Person.FullName;
     Gender          = relationship.Person.Gender;
     BirthDate       = relationship.Person.BirthDate;
     ClientId        = relationship.ClientId;
     RelatedClientId = relationship.RelatedClientId;
     IsIndex         = null != relationship.IsIndex && relationship.IsIndex.Value;
 }
Ejemplo n.º 4
0
        public static ClientStageRelationship Create(ClientRelationship relationship, SubscriberSystem subscriber)
        {
            var clientStage = new ClientStageRelationship();

            if (null != relationship)
            {
                clientStage.IndexClientId     = relationship.ClientId;
                clientStage.IsPartner         = relationship.IsPartner;
                clientStage.SecondaryClientId = relationship.RelatedClientId;
                clientStage.Relation          = subscriber.GetTranslation(relationship.RelationshipTypeId, "Relationship", "0").SafeConvert <int>();;
            }

            return(clientStage);
        }
Ejemplo n.º 5
0
        public void SmartSync(ClientInfo client)
        {
            // IDS
            var clientIdentifiers = ClientIdentifier.Create(client.Identifiers);

            client.Identifiers = new List <IdentifierInfo>();

            // RELATIONSHIPS
            var clientRelationships = ClientRelationship.Create(client.Relationships);

            client.Relationships = new List <RelationshipInfo>();

            //STATES
            var states = client.ClientStates;

            client.ClientStates = new List <ClientStateInfo>();

            // PERSON
            var personInfo     = client.Person;
            var exisitngPerson = _personRepository.GetDemographics(personInfo.Id);

            try
            {
                if (null == exisitngPerson)
                {
                    var person = Person.CreateClient(personInfo);
                    _personRepository.Insert(person);
                    _personRepository.Save();

                    //client
                    var cient = Client.Create(client, client.PracticeId.Value, person.Id);


                    _clientRepository.Insert(cient);
                    _clientRepository.Save();
                }
                else
                {
                    exisitngPerson.UpdateClient(personInfo);
                    _personRepository.Update(exisitngPerson);
                    _personRepository.Save();

                    var existingClient = _clientRepository.GetClient(client.Id, false);

                    if (null != existingClient)
                    {
                        existingClient.Update(client);
                        _clientRepository.Update(existingClient);
                        _clientRepository.Save();
                    }
                    else
                    {
                        var cient = Client.Create(client, client.PracticeId.Value, exisitngPerson.Id);

                        _clientRepository.Insert(cient);
                        _clientRepository.Save();
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e, "Error saving Client");
                Preserve(client);
                return;
            }


            //STATES
            var allstates = Mapper.Map <List <ClientState> >(states);

            _clientRepository.UpdateClientState(client.Id, allstates);

            //IDS
            if (clientIdentifiers.Any())
            {
                _clientRepository.UpdateIds(clientIdentifiers);
                // _clientRepository.Save();
            }

            // RELATIONSHIPS
            if (clientRelationships.Any())
            {
                _clientRepository.UpdateTempRelations(clientRelationships);
                _clientRepository.UpdateRelationships();
            }
        }