Exemple #1
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));
            }
        }