コード例 #1
0
        private AgentRelationshipRM CreateAgentRelationshipForPrincipal(Commands.V1.AgentRelationship.CreateForPrincipal cmd)
        {
            AgentRelationship agentRelationship = AgentRelationship.Create(_agentRelationships++, cmd.IsActive, cmd.EndDate,
                                                                           cmd.AgentId, cmd.PrincipalId, cmd.StartDate);

            if (_repository.AgentRelationshipExistsForPrincipal(agentRelationship, cmd.PrincipalId))
            {
                throw new InvalidOperationException($"Agent Relationship already exists for Associate Principal {cmd.PrincipalId}");
            }

            _repository.AddAgentRelationship(agentRelationship);

            return(Conversions.GetAgentRelationshipRM(agentRelationship));
        }