private static AddressRM AddPrimaryAddressForAssociate(AssociateRM associateRM) { Console.WriteLine("EFTEST: Setting up primary address for Associate " + associateRM.LongName); Commands.V1.Associate.Address.CreateForAssociate createAddressCommand = new Commands.V1.Associate.Address.CreateForAssociate { AssociateId = associateRM.Id, AddressType = (int)AddressTypeLookup.AddressTypeEnum.Physical, Address1 = "401 Bloombridge Way", City = "Marietta", GeographicState = 1, PostalCode = "30066", Country = 1, StartDate = DateTime.Now.Date, IsPrimary = true, IsActive = true }; if (_technologyType != 1) { throw new InvalidOperationException("AddPrimaryAddressForAssociate not supported for REST"); } return((AddressRM)_appService.Handle(createAddressCommand).Result); }
private static OperatingContextRM GetOperatingContextForAssociate(AssociateRM associateRM) { Commands.V1.OperatingContext.Create createOperatingContextCommand = new Commands.V1.OperatingContext.Create { ActingBATypeID = 1, PrimaryAddressId = 1, Status = 1, CertificationId = 1, OperatingContextType = 1, IsDeactivating = false, ThirdPartySupplierId = 1, FacilityId = 1, ProviderType = 1, LegacyId = 1, PrimaryPhoneId = 1, PrimaryEmailId = 1, StartDate = DateTime.Now }; Commands.V1.OperatingContext.CreateForAssociate createOperatingContextForAssociateCommand = new Commands.V1.OperatingContext.CreateForAssociate(associateRM.Id, createOperatingContextCommand); return(_technologyType == 1 ? (OperatingContextRM)_appService.Handle(createOperatingContextForAssociateCommand).Result : CreateOperatingContextForAssociateWithREST(associateRM.Id, createOperatingContextCommand)); }
private static OperatingContextRM AddOperatingContextForAssociate(AssociateRM associateRM) { Console.WriteLine("EFTEST: Setting up operating context for Associate " + associateRM.LongName); Commands.V1.OperatingContext.CreateForAssociate createOperatingContextCommand = new Commands.V1.OperatingContext.CreateForAssociate { AssociateId = associateRM.Id, ActingBATypeID = 1, PrimaryAddressId = 1, Status = 1, FacilityId = associateRM.Id, PrimaryPhoneId = 1, OperatingContextType = (int)OperatingContextTypeLookup.OperatingContextTypeEnum.Internal, IsDeactivating = false, PrimaryEmailId = 1, StartDate = DateTime.Now }; if (_technologyType != 1) { throw new InvalidOperationException("AddOperatingContextForAssociate not supported for REST"); } return((OperatingContextRM)_appService.Handle(createOperatingContextCommand).Result); }
private static void AddBusinessAssociate() { AssociateRM agl = CreateAssociate_AtlantaGasLight(); AddPrimaryPhoneForAssociate(agl, PhoneTypeLookup.PhoneTypeEnum.Office, 6783242548); AddPrimaryEMailForAssociate(agl, "*****@*****.**"); }
public async Task <IActionResult> PostAssociate([FromBody] Commands.V1.Associate.Create request) { object x = await _appService.Handle(request); AssociateRM associateRM = (AssociateRM)x; return(CreatedAtAction("PostAssociate", associateRM)); }
private static CustomerRM CreateCustomer_WalMart(AssociateRM associateRM) { Console.WriteLine("EFTEST: Setting up WalMart customer for Associate"); Commands.V1.Customer.Create createCustomerCommand = new Commands.V1.Customer.Create { StartDate = DateTime.Now, AccountNumber = "12345678", AlternateCustomerId = 1, BalancingLevelId = 1, BasicPoolId = 1, ContractTypeId = 1, CurrentDemand = 1, DUNSNumber = _dunsNumber++, DailyInterruptible = 1, DeliveryLocationId = 1, DeliveryPressure = 1, CustomerTypeId = 1, DeliveryTypeId = 1, EndDate = DateTime.Now.AddYears(10), IsFederal = false, MDQ = 1, GroupTypeId = 1, LongName = "WalMart", TurnOffDate = DateTime.Now.AddYears(10), PreviousDemand = 1, SS1 = false, NominationLevelId = 1, MaxHourlyInterruptible = 1, NAICSCode = 1245, MaxDailyInterruptible = 1, StatusCodeId = 1, ShipperId = 1, HourlyInterruptible = 1, LDCId = 1, SICCode = 1, InterstateSpecifiedFirm = 1, TotalDailySpecifiedFirm = 1, ShortName = "WMT", SICCodePercentage = 1, ShippersLetterToDate = DateTime.Now.AddYears(1), IntrastateSpecifiedFirm = 1, MaxHourlySpecifiedFirm = 1, TotalHourlySpecifiedFirm = 1, ShippersLetterFromDate = DateTime.Now.AddYears(-1), LossTierTypeId = 1, TurnOnDate = DateTime.Now.AddYears(-1) }; Commands.V1.Customer.CreateForAssociate createCustomerForAssociateCommand = new Commands.V1.Customer.CreateForAssociate(associateRM.Id, createCustomerCommand); return(_technologyType == 1 ? (CustomerRM)_appService.Handle(createCustomerForAssociateCommand).Result : CreateCustomerForAssociateWithREST(createCustomerForAssociateCommand)); }
private static void AddInternalBusinessAssociate() { // Generic business associate setup first AssociateRM agl = CreateAssociate_AtlantaGasLight(); PhoneRM phoneRM = AddPrimaryPhoneForAssociate(agl, PhoneTypeLookup.PhoneTypeEnum.Office, 6783242548); EMailRM emailRM = AddPrimaryEMailForAssociate(agl, "*****@*****.**"); AddressRM addressRM = AddPrimaryAddressForAssociate(agl); // Add contact ContactRM contactRM = AddContactForAssociate(agl, addressRM.Id, phoneRM.Id, emailRM.Id, "Joe", "Francis"); // Add operating context OperatingContextRM operatingContextRM = AddOperatingContextForAssociate(agl); }
static void DirectTest() { AssociateRM associateRM = CreateAssociate_AtlantaGasLight(); IEnumerable <AssociateRM> associates = GetListOfAssociates(); ContactRM contactRM = CreateContact_JoeFrancis(associateRM); UserRM userRM = CreateUserForContact(associateRM, contactRM); CustomerRM customerRM = CreateCustomer_WalMart(associateRM); OperatingContextRM operatingContextRM = GetOperatingContext(customerRM); OperatingContextRM operatingContextForAssociateRM = GetOperatingContextForAssociate(associateRM); SetUpAGLServicesAgent(); CreateUserForAgent(contactRM, associateRM); AssociateRM assetManagerRM = SetUpThirdPartyAssetManager(); SetUpAssociateAsPredecessor(); }
private static EMailRM AddPrimaryEMailForAssociate(AssociateRM associateRM, string eMailAddress) { Console.WriteLine("EFTEST: Setting up primary email for Associate " + associateRM.LongName); Commands.V1.Associate.EMail.CreateForAssociate createEMailCommand = new Commands.V1.Associate.EMail.CreateForAssociate { AssociateId = associateRM.Id, EMailAddress = eMailAddress, IsPrimary = true }; if (_technologyType != 1) { throw new InvalidOperationException("AddPrimaryEMailForAssociate not supported for REST"); } return((EMailRM)_appService.Handle(createEMailCommand).Result); }
private static UserRM CreateUserForContact(AssociateRM associateRM, ContactRM contactRM) { Console.WriteLine("EFTEST: Setting up Joe Francis User from Joe Francis contact"); Commands.V1.User.Create createUserCommand = new Commands.V1.User.Create { ContactId = contactRM.Id, IDMSSID = "1", DepartmentCodeId = 1, HasEGMSAccess = true, IsActive = true, IsInternal = true }; Commands.V1.User.CreateForAssociate createUserForAssociateCommand = new Commands.V1.User.CreateForAssociate(associateRM.Id, createUserCommand); return(_technologyType == 1 ? (UserRM)_appService.Handle(createUserForAssociateCommand).Result : CreateUserForAssociateWithREST(createUserForAssociateCommand)); }
private static UserRM CreateUserForAgent(ContactRM contactRM, AssociateRM associateRM) { Console.WriteLine("EFTEST: Create User for Agent"); Commands.V1.User.Create createUserCommandForAgent = new Commands.V1.User.Create { IsActive = true, IsInternal = true, ContactId = contactRM.Id, HasEGMSAccess = true, IDMSSID = "1", DeactivationDate = DateTime.Now.AddYears(10), DepartmentCodeId = 1 }; Commands.V1.User.CreateForAssociate createUserForAgent = new Commands.V1.User.CreateForAssociate(associateRM.Id, createUserCommandForAgent); return(_technologyType == 1 ? (UserRM)_appService.Handle(createUserForAgent).Result : CreateUserForAssociateWithREST(createUserForAgent)); }
private static PhoneRM AddPrimaryPhoneForAssociate(AssociateRM associateRM, PhoneTypeLookup.PhoneTypeEnum phoneType, long phoneNumber) { Console.WriteLine("EFTEST: Setting up primary phone for Associate " + associateRM.LongName); Commands.V1.Associate.Phone.CreateForAssociate createPhoneCommand = new Commands.V1.Associate.Phone.CreateForAssociate { AssociateId = associateRM.Id, IsPrimary = true, Extension = null, PhoneTypeId = (int)phoneType, PhoneNumber = phoneNumber }; if (_technologyType != 1) { throw new InvalidOperationException("AddPrimaryPhoneForAssociate not supported for REST"); } return((PhoneRM)_appService.Handle(createPhoneCommand).Result); }
private static ContactRM CreateContact_JoeFrancis(AssociateRM associateRM) { Console.WriteLine("EFTEST: Setting up Joe Francis contact"); Commands.V1.Contact.Create createContactCommand = new Commands.V1.Contact.Create { PrimaryAddressId = 1, IsActive = true, PrimaryPhoneId = 1, LastName = "Francis", PrimaryEmailId = 1, FirstName = "Joe", Title = "Mr." }; Commands.V1.Contact.CreateForAssociate createContactForAssociateCommand = new Commands.V1.Contact.CreateForAssociate(associateRM.Id, createContactCommand); Console.WriteLine("EFTEST: Getting ContactRM"); return(_technologyType == 1 ? (ContactRM)_appService.Handle(createContactForAssociateCommand).Result : CreateContactForAssociateWithREST(associateRM.Id, createContactCommand)); }
private static ContactRM AddContactForAssociate(AssociateRM associateRM, int primaryAddressId, int primaryPhoneId, int primaryEMailId, string firstName, string lastName) { Console.WriteLine("EFTEST: Adding contact for Associate " + associateRM.LongName); Commands.V1.Contact.CreateForAssociate createContactCommand = new Commands.V1.Contact.CreateForAssociate { PrimaryAddressId = primaryAddressId, IsActive = true, PrimaryPhoneId = primaryPhoneId, LastName = lastName, PrimaryEmailId = primaryEMailId, FirstName = firstName, Title = "Mr." }; if (_technologyType != 1) { throw new InvalidOperationException("AddContactForAssociate not supported for REST"); } return((ContactRM)_appService.Handle(createContactCommand).Result); }
private static PhoneRM AddPrimaryEmailForAssociate(AssociateRM associateRM, PhoneTypeLookup.PhoneTypeEnum phoneType) { return(new PhoneRM()); }
public void CreateAssociate() { var mapperConfig = new MapperConfiguration(cfg => { cfg.CreateMap <Associate, AssociateRM>(); }); IMapper mapper = new Mapper(mapperConfig); ILoggerFactory loggerFactory = new NullLoggerFactory(); ILogger <AssociateRepositoryEF> logger = new Logger <AssociateRepositoryEF>(loggerFactory); BusinessAssociatesContext context = new BusinessAssociatesContext(); AssociateRepositoryEF repository = new AssociateRepositoryEF(context, logger, mapper); AssociatesApplicationService appService = new AssociatesApplicationService(repository, mapper); // Set up Associate Debug.WriteLine("EFTEST: Setting up Internal Associate Atlanta Gas Light"); Commands.V1.Associate.Create createAssociateCommand = new Commands.V1.Associate.Create { AssociateTypeId = (int)AssociateTypeLookup.AssociateTypeEnum.InternalLDCFacility, DUNSNumber = _dunsNumber++, IsDeactivating = false, IsInternal = true, IsParent = false, LongName = "Atlanta Gas Light", ShortName = "AGL", StatusCodeId = (int)StatusCodeLookup.StatusCodeEnum.Active }; Debug.WriteLine("EFTEST: Getting AssociateRM"); AssociateRM associateRM = (AssociateRM)appService.Handle(createAssociateCommand).Result; // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Set up Contact Debug.WriteLine("EFTEST: Setting up Joe Francis contact"); Commands.V1.Contact.Create createContactCommand = new Commands.V1.Contact.Create { PrimaryAddressId = 1, IsActive = true, PrimaryPhoneId = 1, LastName = "Francis", PrimaryEmailId = 1, FirstName = "Joe", Title = "Mr." }; Commands.V1.Contact.CreateForAssociate createContactForAssociateCommand = new Commands.V1.Contact.CreateForAssociate(associateRM.Id, createContactCommand); Debug.WriteLine("EFTEST: Getting ContactRM"); ContactRM contactRM = (ContactRM)appService.Handle(createContactForAssociateCommand).Result; // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Debug.WriteLine("EFTEST: Setting up Joe Francis contact"); Commands.V1.Contact.Address.Create createAddressCommand = new Commands.V1.Contact.Address.Create { StartDate = DateTime.Now, Address1 = "401 Bloombridge Way", AddressType = (int)AddressTypeLookup.AddressTypeEnum.Physical, Attention = "Joe Francis", City = "Marietta", Country = 1, GeographicState = 1, EndDate = DateTime.Now.AddYears(10), IsActive = true, Comments = "None", PostalCode = "30066", IsPrimary = true }; Commands.V1.Contact.Address.CreateForContact createAddressForContactCommand = new Commands.V1.Contact.Address.CreateForContact(contactRM.Id, createAddressCommand); Debug.WriteLine("EFTEST: Getting AddressRM"); // ReSharper disable once UnusedVariable AddressRM addressRM = (AddressRM)appService.Handle(createAddressForContactCommand).Result; // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Set up User for Contact Debug.WriteLine("EFTEST: Setting up Joe Francis User from Joe Francis contact"); Commands.V1.User.Create createUserCommand = new Commands.V1.User.Create { ContactId = contactRM.Id, IDMSSID = "1", DepartmentCodeId = 1, HasEGMSAccess = true, IsActive = true, IsInternal = true }; Commands.V1.User.CreateForAssociate createUserForAssociateCommand = new Commands.V1.User.CreateForAssociate(associateRM.Id, createUserCommand); Debug.WriteLine("EFTEST: Getting UserRM"); // ReSharper disable once UnusedVariable UserRM userRM = (UserRM)appService.Handle(createUserForAssociateCommand).Result; // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Set up Customer for Associate - can we get rid of this and just use relationship object Debug.WriteLine("EFTEST: Setting up WalMart customer for Associate"); Commands.V1.Customer.Create createCustomerCommand = new Commands.V1.Customer.Create { StartDate = DateTime.Now, AccountNumber = "12345678", AlternateCustomerId = 1, BalancingLevelId = 1, BasicPoolId = 1, ContractTypeId = 1, CurrentDemand = 1, DUNSNumber = _dunsNumber++, DailyInterruptible = 1, DeliveryLocationId = 1, DeliveryPressure = 1, CustomerTypeId = 1, DeliveryTypeId = 1, EndDate = DateTime.Now.AddYears(10), IsFederal = false, MDQ = 1, GroupTypeId = 1, LongName = "WalMart", TurnOffDate = DateTime.Now.AddYears(10), PreviousDemand = 1, SS1 = false, NominationLevelId = 1, MaxHourlyInterruptible = 1, NAICSCode = 1245, MaxDailyInterruptible = 1, StatusCodeId = 1, ShipperId = 1, HourlyInterruptible = 1, LDCId = 1, SICCode = 1, InterstateSpecifiedFirm = 1, TotalDailySpecifiedFirm = 1, ShortName = "WMT", SICCodePercentage = 1, ShippersLetterToDate = DateTime.Now.AddYears(1), IntrastateSpecifiedFirm = 1, MaxHourlySpecifiedFirm = 1, TotalHourlySpecifiedFirm = 1, ShippersLetterFromDate = DateTime.Now.AddYears(-1), LossTierTypeId = 1, TurnOnDate = DateTime.Now.AddYears(-1) }; Commands.V1.Customer.CreateForAssociate createCustomerForAssociateCommand = new Commands.V1.Customer.CreateForAssociate(associateRM.Id, createCustomerCommand); Debug.WriteLine("EFTEST: Getting CustomerRM"); // ReSharper disable once NotAccessedVariable CustomerRM customerRM = (CustomerRM)appService.Handle(createCustomerForAssociateCommand).Result; // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Set Up Operating Context Commands.V1.OperatingContext.Create createOperatingContextCommand = new Commands.V1.OperatingContext.Create { ActingBATypeID = 1, PrimaryAddressId = 1, Status = 1, CertificationId = 1, OperatingContextType = 1, IsDeactivating = false, ThirdPartySupplierId = 1, FacilityId = 1, ProviderType = 1, LegacyId = 1, PrimaryPhoneId = 1, PrimaryEmailId = 1, StartDate = DateTime.Now }; Commands.V1.OperatingContext.CreateForCustomer createOperatingContextForCustomerCommand = new Commands.V1.OperatingContext.CreateForCustomer(customerRM.Id, createOperatingContextCommand); Debug.WriteLine("EFTEST: Getting OperatingContextRM for Customer"); // ReSharper disable once NotAccessedVariable // ReSharper disable once UnusedVariable OperatingContextRM operatingContextRM = (OperatingContextRM)appService.Handle(createOperatingContextForCustomerCommand).Result; // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Set up relationship between Associate and OperatingContext Debug.WriteLine("EFTEST: Getting OperatingContextRM for Associate"); // ReSharper disable once NotAccessedVariable Commands.V1.OperatingContext.CreateForAssociate createOperatingContextForAssociateCommand = new Commands.V1.OperatingContext.CreateForAssociate(associateRM.Id, createOperatingContextCommand); // ReSharper disable once UnusedVariable OperatingContextRM operatingContextForAssociateRM = (OperatingContextRM)appService.Handle(createOperatingContextForAssociateCommand).Result; // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Set up Associate as Agent // Set up Associate Debug.WriteLine("EFTEST: Setting up AGL Services Agent"); Commands.V1.Associate.Create createAssociateCommandForAgent = new Commands.V1.Associate.Create { AssociateTypeId = ExternalAssociateTypeLookup.ActingAssociateTypes[(int)ExternalAssociateTypeLookup.ExternalAssociateTypeEnum.AssetManager].ActingAssociateTypeId, DUNSNumber = _dunsNumber++, IsDeactivating = false, IsInternal = true, IsParent = false, LongName = "AGL Services", ShortName = "SCS", StatusCodeId = (int)StatusCodeLookup.StatusCodeEnum.Active }; Debug.WriteLine("EFTEST: Getting AssociateRM for Agent"); // ReSharper disable once NotAccessedVariable // ReSharper disable once UnusedVariable AssociateRM agentRM = (AssociateRM)appService.Handle(createAssociateCommandForAgent).Result; // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // AddAssociate User to Agent Debug.WriteLine("EFTEST: Create User for Agent"); Commands.V1.User.Create createUserCommandForAgent = new Commands.V1.User.Create { IsActive = true, IsInternal = true, ContactId = contactRM.Id, HasEGMSAccess = true, IDMSSID = "1", DeactivationDate = DateTime.Now.AddYears(10), DepartmentCodeId = 1 }; Commands.V1.User.CreateForAssociate createUserForAgent = new Commands.V1.User.CreateForAssociate(associateRM.Id, createUserCommandForAgent); Debug.WriteLine("EFTEST: Getting UserRM for Agent"); // ReSharper disable once NotAccessedVariable // ReSharper disable once UnusedVariable UserRM userRM2 = (UserRM)appService.Handle(createUserForAgent).Result; // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Set up Asset Manager for Associate for Third-Party Suppliers Debug.WriteLine("EFTEST: Set up third party asset manager"); Commands.V1.Associate.Create createAssetManagerForTPS = new Commands.V1.Associate.Create { AssociateTypeId = ExternalAssociateTypeLookup.ActingAssociateTypes[(int)ExternalAssociateTypeLookup.ExternalAssociateTypeEnum.AssetManager].ActingAssociateTypeId, DUNSNumber = _dunsNumber++, IsDeactivating = false, IsInternal = true, IsParent = false, LongName = "AGL Services", ShortName = "SCS", StatusCodeId = (int)StatusCodeLookup.StatusCodeEnum.Active }; Debug.WriteLine("EFTEST: Get AssociateRM for third party"); // ReSharper disable once NotAccessedVariable // ReSharper disable once UnusedVariable AssociateRM assetManagerRM = (AssociateRM)appService.Handle(createAssetManagerForTPS).Result; // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Set up Associate as predecessor Debug.WriteLine("EFTEST: Set up associate as predecessor"); Commands.V1.Associate.Create createPredecessor = new Commands.V1.Associate.Create { AssociateTypeId = (int)AssociateTypeLookup.AssociateTypeEnum.InternalLDCFacility, DUNSNumber = _dunsNumber++, IsDeactivating = false, IsInternal = true, IsParent = false, LongName = "AGL Services", ShortName = "SCS", StatusCodeId = (int)StatusCodeLookup.StatusCodeEnum.Active }; Debug.WriteLine("EFTEST: Get PredecessorManagerRM for predecessor"); // ReSharper disable once NotAccessedVariable // ReSharper disable once UnusedVariable AssociateRM predecessorManagerRM = (AssociateRM)appService.Handle(createPredecessor).Result; }