private void LoadProviders() { ddlProviders.ClearSelection(); foreach (var shippingService in AvailableServices.FindAll(HccApp.CurrentStore)) { ddlProviders.Items.Add(new RadComboBoxItem(shippingService.Name, shippingService.Id)); } }
private void LoadProviders() { lstProviders.ClearSelection(); foreach (var p in AvailableServices.FindAll(HccApp.CurrentStore)) { lstProviders.Items.Add(new ListItem(p.Name, p.Id)); } }
private void MigrateFedExRateSetting() { // 1.9.0: negotiated rates are no longer a global setting, but a "local" setting var context = new HccRequestContext(); var accountServices = Factory.CreateService <AccountService>(context); var stores = accountServices.Stores.FindAllPaged(1, int.MaxValue); foreach (var store in stores) { context.CurrentStore = store; var fedExService = AvailableServices.FindAll(store).FirstOrDefault(s => s.GetType() == typeof(FedExProvider)); if (fedExService != null) { var oldNegotiationRateValue = true; var oldNegotiationRateSetting = store.Settings.AllSettings.FirstOrDefault(s => s.SettingName == "ShippingFedExUseListRates"); if (oldNegotiationRateSetting != null) { // reversing the logic since the previous setting was citing LIST rates and not negotiated rates oldNegotiationRateValue = !oldNegotiationRateSetting.SettingValueAsBool; } // get all fedex methods var orderService = Factory.CreateService <OrderService>(context); var methods = orderService.ShippingMethods.FindAll(store.Id) .Where(m => m.ShippingProviderId == fedExService.Id); foreach (var method in methods) { // update each FedEx shipping method instance with a local setting, using the original global value as a default var settings = new FedExServiceSettings(); settings.Merge(method.Settings); settings["UseNegotiatedRates"] = oldNegotiationRateValue.ToString(); method.Settings.Merge(settings); orderService.ShippingMethods.Update(method); } // get rid of the old global setting if (oldNegotiationRateSetting != null) { var settingsRepo = Factory.CreateRepo <StoreSettingsRepository>(context); settingsRepo.Delete(oldNegotiationRateSetting.Id); } } CacheManager.ClearForStore(store.Id); } }
public void LoadServiceCodes() { //Arrange var count = _irepo.GetUpsServiceCodeCount(); //Act var resultcount = AvailableServices.FindAll(_application.CurrentStore).FirstOrDefault(x => x.Name.Equals("UPS")).ListAllServiceCodes().Count; //Assert Assert.AreEqual(count, resultcount); }
public void LoadTotalShippingMethods() { //Arrange var store = _application.CurrentStore; var storesmethod = AvailableServices.FindAll(store); //Act var resultcount = _irepo.GetTotalShippingMethodCount(); //Assert Assert.AreEqual(storesmethod.Count, resultcount); }
/// <summary> /// Sets the services filter code. /// </summary> /// <param name="name">The name.</param> /// <param name="serviceCodeFilter">The service code filter.</param> /// <returns></returns> private List <IServiceCode> SetServicesFilterCode(string name, IEnumerable <IServiceCode> serviceCodeFilter) { try { var servicecodes = AvailableServices.FindAll(_application.CurrentStore) .FirstOrDefault(x => x.Name.Equals(name)) .ListAllServiceCodes(); return(serviceCodeFilter.Select(filter => servicecodes.FirstOrDefault(x => x.DisplayName.Equals(filter.DisplayName))).ToList()); } catch (Exception) { return(new List <IServiceCode>()); } }
/// <summary> /// A collection of the tokens and the replaceable content for email templates. /// </summary> /// <param name="context">An instance of the Hotcakes Request context.</param> /// <returns>List of HtmlTemplateTag</returns> public List <HtmlTemplateTag> GetReplaceableTags(HccRequestContext context) { var result = new List <HtmlTemplateTag>(); result.Add(new HtmlTemplateTag("[[Package.ShipDate]]", ShipDateUtc.ToString("d"))); if (TrackingNumber == string.Empty) { result.Add(new HtmlTemplateTag("[[Package.TrackingNumber]]", "None Available")); } else { result.Add(new HtmlTemplateTag("[[Package.TrackingNumber]]", TrackingNumber)); } var tagsEntered = false; var currentStore = context.CurrentStore; foreach (var item in AvailableServices.FindAll(currentStore)) { if (item.Id == ShippingProviderId) { tagsEntered = true; var trackingUrl = string.Empty; if (item.IsSupportsTracking && !string.IsNullOrEmpty(TrackingNumber)) { trackingUrl = item.GetTrackingUrl(TrackingNumber); result.Add(new HtmlTemplateTag("[[Package.TrackingNumberMarkup]]", string.Format(TrackingNumberMarkup, trackingUrl, TrackingNumber))); } else { result.Add(new HtmlTemplateTag("[[Package.TrackingNumberMarkup]]", TrackingNumber)); } result.Add(new HtmlTemplateTag("[[Package.TrackingNumberLink]]", trackingUrl)); var serviceCodes = item.ListAllServiceCodes(); var shipperServiceFound = false; foreach (var serviceCode in serviceCodes) { if (string.Compare(ShippingProviderServiceCode, serviceCode.Code, true) == 0) { shipperServiceFound = true; result.Add(new HtmlTemplateTag("[[Package.ShipperService]]", serviceCode.DisplayName)); break; } } var shipperName = string.Empty; var orderService = Factory.CreateService <OrderService>(context); var order = orderService.Orders.FindForCurrentStore(OrderId); if (order != null && order.bvin != string.Empty) { if (!string.IsNullOrEmpty(ShippingMethodId)) { var shippingMethod = orderService.ShippingMethods.Find(ShippingMethodId); shipperName = shippingMethod.Name; } else { if (shipperServiceFound) { shipperName = item.Name; } else { shipperName = order.ShippingMethodDisplayName; } } } if (!shipperServiceFound) { result.Add(new HtmlTemplateTag("[[Package.ShipperService]]", shipperName)); } result.Add(new HtmlTemplateTag("[[Package.ShipperName]]", shipperName)); } } if ((Items != null) && (Items.Count > 0)) { var sb = new StringBuilder(); sb.Append("<table class=\"packageitems\">"); sb.Append("<tr>"); sb.Append("<td class=\"itemnamehead\">Name</td>"); sb.Append("<td class=\"itemquantityhead\">Quantity</td>"); sb.Append("</tr>"); //sb.Append("<ul>") var count = 0; foreach (var item in Items) { if (item.Quantity > 0) { if (count % 2 == 0) { sb.Append("<tr>"); } else { sb.Append("<tr class=\"alt\">"); } //sb.Append("<li>") var productRepository = Factory.CreateRepo <ProductRepository>(context); var prod = productRepository.FindWithCache(item.ProductBvin); if (prod != null) { sb.Append("<td class=\"itemname\">"); sb.Append(prod.ProductName); sb.Append("</td>"); sb.Append("<td class=\"itemquantity\">"); sb.Append(item.Quantity.ToString()); sb.Append("</td>"); } //sb.Append("</li>") sb.Append("</tr>"); count += 1; } } sb.Append("</table>"); //sb.Append("</ul>") result.Add(new HtmlTemplateTag("[[Package.Items]]", sb.ToString())); } else { result.Add(new HtmlTemplateTag("[[Package.Items]]", string.Empty)); } //these are only here so that they get added to the list of available tags if (!tagsEntered) { result.Add(new HtmlTemplateTag("[[Package.TrackingNumberLink]]", string.Empty)); result.Add(new HtmlTemplateTag("[[Package.TrackingNumberMarkup]]", string.Empty)); result.Add(new HtmlTemplateTag("[[Package.ShipperName]]", string.Empty)); result.Add(new HtmlTemplateTag("[[Package.ShipperService]]", string.Empty)); } return(result); }
/// <summary> /// Gets the shipping provider identifier. /// </summary> /// <param name="name">The name.</param> /// <returns></returns> private string GetShippingProviderId(string name) { return(AvailableServices.FindAll(_application.CurrentStore) .FirstOrDefault(x => x.Name.Equals(name)) .Id); }