public Task <UserRM> GetUserForAgentRelationship(int principalId, int agentRelationshipId, int userId) { ValidateAssociateExists(principalId); AgentRelationship agentRelationship = ValidateAgentRelationshipExists(principalId, agentRelationshipId); ValidateAgentUsersExist(agentRelationship); return(GetUser(userId)); }
private List <AgentUser> ValidateAgentUsersExist(AgentRelationship agentRelationship) { List <AgentUser> agentUsers = _context.AgentUsers.Where(au => au.AgentId == agentRelationship.AgentId).ToList(); if (agentUsers == null) { throw new InvalidOperationException("Users not found for AgentRelationship."); } return(agentUsers); }
public static AgentRelationshipRM GetAgentRelationshipRM(AgentRelationship agentRelationship) { return(new AgentRelationshipRM { Id = agentRelationship.Id, StartDate = agentRelationship.StartDate, IsActive = agentRelationship.IsActive, AgentId = agentRelationship.AgentId, PrincipalId = agentRelationship.PrincipalId }); }
private AgentRelationship ValidateAgentRelationshipExists(int principalId, int agentRelationshipId) { AgentRelationship agentRelationship = _context.AgentRelationships.SingleOrDefault(ar => ar.PrincipalId == principalId && ar.Id == agentRelationshipId); if (agentRelationship == null) { throw new InvalidOperationException("Agent relationship not found for specified principal."); } return(agentRelationship); }
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)); }
public Task <PagedGridResult <IEnumerable <UserRM> > > GetUsersForAgentRelationship(int principalId, int agentRelationshipId) { ValidateAssociateExists(principalId); AgentRelationship agentRelationship = ValidateAgentRelationshipExists(principalId, agentRelationshipId); IEnumerable <AgentUser> agentUsers = ValidateAgentUsersExist(agentRelationship); List <User> users = agentUsers .Select(agentUser => _context.Users.SingleOrDefault(u => u.Id == agentUser.UserId)) .Where(user => user != null).ToList(); return(Task.FromResult(new PagedGridResult <IEnumerable <UserRM> > { Data = _mapper.Map <IEnumerable <UserRM> >(users), Total = users.Count })); }
public void AddAgentRelationshipForPrincipal(AgentRelationship agentRelationship, int principalId) { throw new NotImplementedException(); }
public bool AgentRelationshipExistsForPrincipal(AgentRelationship agentRelationship, int principalId) { throw new NotImplementedException(); }
public bool AgentRelationshipExistsForPrincipal(AgentRelationship agentRelationship, int principalId) { return(_context.AgentRelationships.FirstOrDefault(ar => ar.PrincipalId == principalId && ar.AgentId == agentRelationship.AgentId) == null); }
public void AddAgentRelationship(AgentRelationship agentRelationship) { _context.AgentRelationships.Add(agentRelationship); }
static void Main() { //internalAssociateController.PutAssociate(); InternalAssociate atlantaGasLight = AddInternalAssociate(123456789, "AtlantaGasLight", "AGL"); ExternalAssociate transco = AddExternalAssociate(123456790, "Transco", "TRX"); // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Add an Operating Context to an internal business associate for a particular LDC atlantaGasLight.AddOperatingContext(); // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Add an External BA Operating Context to an external business associate for a // particular LDC, set the Provider Type to Marketer and generate a new Third-Party Supplier Id for the new operating context. transco.AddOperatingContext(new ExternalOperatingContext(ProviderType.MARKETER)); // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Add an External BA Operating Context to an external business associate for a // particular LDC, set the Provider Type to Pooler and generate a new Third-Party Supplier Id for the new operating context. transco.AddOperatingContext(new ExternalOperatingContext(ProviderType.POOLER)); // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Add an External BA Operating Context to an external business associate for a // particular LDC, set the Provider Type to Shipper and generate a new Third-Party Supplier Id for the new operating context. transco.AddOperatingContext(new ExternalOperatingContext(ProviderType.SHIPPER)); // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Add an External BA Operating Context to an external business associate for a // particular LDC, set the Provider Type to Supplier and generate a new Third-Party Supplier Id for the new operating context. transco.AddOperatingContext(new ExternalOperatingContext(ProviderType.SUPPLIER)); // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Add an External BA Operating Context to an external business associate for a // particular LDC, set the Provider Type to Asset Manager and generate a new Third-Party Supplier Id for the new operating context. transco.AddOperatingContext(new ExternalOperatingContext(ProviderType.ASSET_MANAGER)); // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Update the status of an External BA Operating Context for an external business associate from Pending to Active transco.OperatingContexts[0].Status = Status.ACTIVE; // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Add a new Agent Relationship for two external business associates // TO DO: Add Start Date, End Date DUNSNumber transcoAgentsDUNSNumber = DUNSNumber.Create(123456791).Value; LongName longName = LongName.Create("TranscoAgents").Value; ShortName shortName = ShortName.Create("TRXA").Value; Agent transcoAgents = new Agent(transcoAgentsDUNSNumber, longName, shortName, ExternalAssociateType.SELF_PROVIDER) { OperatingContexts = new List <OperatingContext> { new ExternalOperatingContext() } }; AgentRelationship agentRelationship = new AgentRelationship(transco, transcoAgents); transco.AddAgentRelationship(agentRelationship); Role roleA = new Role(); UserOperatingContext userOperatingContextA = new UserOperatingContext { Role = roleA }; agentRelationship.AgentUserList.Add(userOperatingContextA); // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Terminate an existing Agent Relationship for two external business associates // The specs call for setting the end date, but we have instead added an active flag. agentRelationship.IsActive = false; // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Modify an existing Agent Relationship for two external business associates by adding a // new user to the relationship, modifying the role of a user within a relationship or // remove a user from the relationship. UserOperatingContext userOperatingContextB = new UserOperatingContext(); agentRelationship.AgentUserList.Add(userOperatingContextB); Role roleB = new Role(); userOperatingContextB.Role = roleB; agentRelationship.AgentUserList.Remove(userOperatingContextB); // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Add a new Asset Manager Relationship for an external business associate and an internal business associate AssetManagerRelationship assetManagerRelationship = new AssetManagerRelationship(atlantaGasLight, transcoAgents); transco.AgentRelationships.Add(agentRelationship); assetManagerRelationship.AssetManagerUserList.Add(userOperatingContextA); atlantaGasLight.AssetManagerRelationships.Add(assetManagerRelationship); // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Modify an existing Asset Manager Relationship by adding a new user // to the relationship, modifying the role of a user within a relationship // or remove a user from the relationship. assetManagerRelationship.AssetManagerUserList.Add(userOperatingContextB); userOperatingContextB.Role = roleB; assetManagerRelationship.AssetManagerUserList.Remove(userOperatingContextA); // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // JOEF: Assuming that this is not a legitimate use case until we get clarification // Designate an external business associate as a shipper for a particular market }