public static ZohoContact Map(ZohoContact contact, HSBuyer buyer, IList <HSUser> users, ZohoCurrency currency, HSBuyerLocation location) { contact.company_name = $"{buyer.Name} - {location.Address?.xp.LocationID}"; contact.contact_name = $"{location.Address?.AddressName} - {location.Address?.xp.LocationID}"; contact.contact_type = "customer"; contact.billing_address = ZohoAddressMapper.Map(location.Address); contact.shipping_address = ZohoAddressMapper.Map(location.Address); contact.contact_persons = ZohoContactMapper.Map(users, contact); contact.currency_id = currency.currency_id; contact.notes = $"Franchise ID: {buyer.ID} ~ Location ID: {location.Address?.xp.LocationID}"; return(contact); }
public static ZohoContact Map(HSBuyer buyer, IList <HSUser> users, ZohoCurrency currency, HSBuyerLocation location) { return(new ZohoContact() { company_name = $"{buyer.Name} - {location.Address?.xp.LocationID}", contact_name = $"{location.Address?.AddressName} - {location.Address?.xp.LocationID}", contact_type = "customer", billing_address = ZohoAddressMapper.Map(location.Address), shipping_address = ZohoAddressMapper.Map(location.Address), contact_persons = ZohoContactMapper.Map(users), currency_id = currency.currency_id, notes = $"Franchise ID: {buyer.ID} ~ Location ID: {location.Address?.xp.LocationID}" }); }
public async Task <HSBuyer> CreateBuyerAndRelatedFunctionalResources(HSBuyer buyer, VerifiedUserContext user, bool isSeedingEnvironment = false) { var token = isSeedingEnvironment ? user.AccessToken : null; buyer.ID = "{buyerIncrementor}"; buyer.Active = true; var ocBuyer = await _oc.Buyers.CreateAsync(buyer, user.AccessToken); buyer.ID = ocBuyer.ID; var ocBuyerID = ocBuyer.ID; // create base security profile assignment await _oc.SecurityProfiles.SaveAssignmentAsync(new SecurityProfileAssignment { BuyerID = ocBuyerID, SecurityProfileID = CustomRole.MPBaseBuyer.ToString() }, token); // list message senders var msList = await _oc.MessageSenders.ListAsync(accessToken : token); // create message sender assignment var assignmentList = msList.Items.Select(ms => { return(new MessageSenderAssignment { MessageSenderID = ms.ID, BuyerID = ocBuyerID }); }); await Throttler.RunAsync(assignmentList, 100, 5, a => _oc.MessageSenders.SaveAssignmentAsync(a, token)); await _oc.Incrementors.CreateAsync(new Incrementor { ID = $"{ocBuyerID}-UserIncrementor", LastNumber = 0, LeftPaddingCount = 5, Name = "User Incrementor" }, token); await _oc.Incrementors.CreateAsync(new Incrementor { ID = $"{ocBuyerID}-LocationIncrementor", LastNumber = 0, LeftPaddingCount = 4, Name = "Location Incrementor" }, token); await _oc.Catalogs.SaveAssignmentAsync(new CatalogAssignment() { BuyerID = ocBuyer.ID, CatalogID = ocBuyer.ID, ViewAllCategories = true, ViewAllProducts = false }, token); return(buyer); }
public async Task <HSBuyer> CreateBuyerAndRelatedFunctionalResources(HSBuyer buyer, string accessToken, IOrderCloudClient oc) { // if we're seeding then use the passed in oc client // to support multiple environments and ease of setup for new orgs // else used the configured client var token = oc == null ? null : accessToken; var ocClient = oc ?? _oc; buyer.ID = buyer.ID ?? "{buyerIncrementor}"; var ocBuyer = await ocClient.Buyers.CreateAsync(buyer, accessToken); var ocBuyerID = ocBuyer.ID; buyer.ID = ocBuyerID; // create base security profile assignment await ocClient.SecurityProfiles.SaveAssignmentAsync(new SecurityProfileAssignment { BuyerID = ocBuyerID, SecurityProfileID = CustomRole.HSBaseBuyer.ToString() }, token); // assign message sender await ocClient.MessageSenders.SaveAssignmentAsync(new MessageSenderAssignment { MessageSenderID = "BuyerEmails", BuyerID = ocBuyerID }, token); await ocClient.Incrementors.SaveAsync($"{ocBuyerID}-UserIncrementor", new Incrementor { ID = $"{ocBuyerID}-UserIncrementor", LastNumber = 0, LeftPaddingCount = 5, Name = "User Incrementor" }, token); await ocClient.Incrementors.SaveAsync($"{ocBuyerID}-LocationIncrementor", new Incrementor { ID = $"{ocBuyerID}-LocationIncrementor", LastNumber = 0, LeftPaddingCount = 4, Name = "Location Incrementor" }, token); await ocClient.Catalogs.SaveAssignmentAsync(new CatalogAssignment() { BuyerID = ocBuyerID, CatalogID = ocBuyerID, ViewAllCategories = true, ViewAllProducts = false }, token); return(buyer); }
public async Task <HSBuyer> CreateBuyerAndRelatedFunctionalResources(HSBuyer buyer, string accessToken, bool isSeedingEnvironment = false) { var token = isSeedingEnvironment ? accessToken : null; buyer.ID = "{buyerIncrementor}"; buyer.Active = true; var ocBuyer = await _oc.Buyers.CreateAsync(buyer, accessToken); buyer.ID = ocBuyer.ID; var ocBuyerID = ocBuyer.ID; // create base security profile assignment await _oc.SecurityProfiles.SaveAssignmentAsync(new SecurityProfileAssignment { BuyerID = ocBuyerID, SecurityProfileID = CustomRole.HSBaseBuyer.ToString() }, token); // assign message sender await _oc.MessageSenders.SaveAssignmentAsync(new MessageSenderAssignment { MessageSenderID = "BuyerEmails", BuyerID = ocBuyer.ID }, token); await _oc.Incrementors.SaveAsync($"{ocBuyerID}-UserIncrementor", new Incrementor { ID = $"{ocBuyerID}-UserIncrementor", LastNumber = 0, LeftPaddingCount = 5, Name = "User Incrementor" }, token); await _oc.Incrementors.SaveAsync($"{ocBuyerID}-LocationIncrementor", new Incrementor { ID = $"{ocBuyerID}-LocationIncrementor", LastNumber = 0, LeftPaddingCount = 4, Name = "Location Incrementor" }, token); await _oc.Catalogs.SaveAssignmentAsync(new CatalogAssignment() { BuyerID = ocBuyer.ID, CatalogID = ocBuyer.ID, ViewAllCategories = true, ViewAllProducts = false }, token); return(buyer); }
public async Task <HSBuyer> PostBuyer([FromBody] HSBuyer obj) { return(await _command.SaveToQueue(obj, this.VerifiedUserContext, obj.ID)); }