public void Setup() { IOC.UnitTest(); IOC.CMSApplication.Mock(out _cmsApplicationMock); IOC.StoreUrlService.UseType<UmbracoStorePickerStoreUrlService>(); IOC.StoreUrlRepository.Actual(); _store = new Store {Id = StoreId}; }
public void NoStorePickers_ShouldGiveNoUrls() { var repo = IOC.StoreUrlRepository.Actual().Resolve(); var store = new Store(); var urls = repo.GetUrls(store.Id); Assert.AreEqual(0, urls.WithDomain.Count()); Assert.AreEqual(0, urls.WithoutDomain.Count()); }
public void PersistingStoreUrl() { IOC.UnitTest(); var store = new Store(); UwebshopRequest.Current.SetStoreUrl(store, "abc"); var actual = UwebshopRequest.Current.GetStoreUrl(store); Assert.AreEqual("abc", actual); }
public void NoStorePickers_NodeWithDomain_ShouldGiveNoUrlsWithoutDomain() { UseNodes(new[] { new UwbsNode{ Level = 1, Id = 1, SortOrder = 0, UrlName = "unused",}, }); var setupNewMock = IOC.CMSApplication.SetupNewMock(); setupNewMock.Setup(m => m.GetDomainsForNodeId(1)).Returns(new[] { "www.domain.com/en" }); var repo = IOC.StoreUrlRepository.Actual().Resolve(); var store = new Store(); var urls = repo.GetUrls(store.Id); Assert.AreEqual("www.domain.com/en/", urls.WithDomain.FirstOrDefault()); Assert.False(urls.WithoutDomain.Any()); }
private static bool GetMultiStorePropertyName(Document sender, Store store, out string propertyName) { propertyName = "url_" + store.Alias.ToLower(); if (sender.getProperty(propertyName) != null) { return(false); } propertyName = "url_" + store.Alias.ToUpper(); if (sender.getProperty(propertyName) != null) { return(false); } propertyName = "url_" + store.Alias; return(sender.getProperty(propertyName) == null); }
public void TriggerStoreChangedEvent(Store store) { foreach (var e in _storeChangedEvents) { e(store); } }
public void LoadStoreUrl(Store store) { }
public Store GetCurrentStore() { var store = GetCurrentStoreNoFallback(); if (store == null) { Log.Instance.LogError("Could not determine current store, fallback cookie"); store = _storeRepository.TryGetStoreFromCookie(); } if (store == null) { Log.Instance.LogError("Could not determine current store, fallback to first store"); store = GetAllStores().OrderBy(x => x.SortOrder).FirstOrDefault(); // fallback } if (store == null || string.IsNullOrEmpty(store.Alias)) { store = new Store {Alias = "uWebshop", GlobalVat = 21, Id = 1, NodeTypeAlias = "uwbsStoreDummy", CountryCode = "nl-NL", Culture = "nl-NL", CurrencyCulture = "nl-NL", IncompleOrderLifetime = 3600, SortOrder = 1, StoreURL = "/", StoreUrlWithoutDomain = "/", CanonicalStoreURL = "/"}; Log.Instance.LogWarning("uWebshop had to make a dummy store, please make sure that a published store exists and republish entire site & rebuild examine index, if this doesn't work please reset the IIS application pool"); } Log.Instance.LogDebug("GetCurrentStore() store: " + store.Alias); UwebshopRequest.Current.CurrentStore = store; return store; }
protected void DocumentAfterPublish(Document sender, PublishEventArgs e) { // when thinking about adding something here, consider ContentOnAfterUpdateDocumentCache! if (sender.Level > 2) { if (sender.ContentType.Alias == Order.NodeAlias || sender.Parent != null && (OrderedProduct.IsAlias(sender.ContentType.Alias) || sender.Parent.Parent != null && OrderedProductVariant.IsAlias(sender.ContentType.Alias))) { var orderDoc = sender.ContentType.Alias == Order.NodeAlias ? sender : (OrderedProduct.IsAlias(sender.ContentType.Alias) && !OrderedProductVariant.IsAlias(sender.ContentType.Alias) ? new Document(sender.Parent.Id) : new Document(sender.Parent.Parent.Id)); if (orderDoc.ContentType.Alias != Order.NodeAlias) { throw new Exception("There was an error in the structure of the order documents"); } // load existing orderInfo (why..? => possibly to preserve information not represented in the umbraco documents) if (string.IsNullOrEmpty(orderDoc.getProperty("orderGuid").Value.ToString())) { Store store = null; var storeDoc = sender.GetAncestorDocuments().FirstOrDefault(x => x.ContentType.Alias == OrderStoreFolder.NodeAlias); if (storeDoc != null) { store = StoreHelper.GetAllStores().FirstOrDefault(x => x.Name == storeDoc.Text); } if (store == null) { store = StoreHelper.GetAllStores().FirstOrDefault(); } var orderInfo = OrderHelper.CreateOrder(store); IO.Container.Resolve <IOrderNumberService>().GenerateAndPersistOrderNumber(orderInfo); orderInfo.Status = OrderStatus.Confirmed; orderInfo.Save(); sender.SetProperty("orderGuid", orderInfo.UniqueOrderId.ToString()); sender.Save(); } else { var orderGuid = Guid.Parse(orderDoc.getProperty("orderGuid").Value.ToString()); var orderInfo = OrderHelper.GetOrderInfo(orderGuid); var order = new Order(orderDoc.Id); orderInfo.CustomerEmail = order.CustomerEmail; orderInfo.CustomerFirstName = order.CustomerFirstName; orderInfo.CustomerLastName = order.CustomerLastName; var dictionaryCustomer = orderDoc.GenericProperties.Where(x => x.PropertyType.Alias.StartsWith("customer")).ToDictionary(customerProperty => customerProperty.PropertyType.Alias, customerProperty => customerProperty.Value.ToString()); orderInfo.AddCustomerFields(dictionaryCustomer, CustomerDatatypes.Customer); var dictionaryShipping = orderDoc.GenericProperties.Where(x => x.PropertyType.Alias.StartsWith("shipping")).ToDictionary(property => property.PropertyType.Alias, property => property.Value.ToString()); orderInfo.AddCustomerFields(dictionaryShipping, CustomerDatatypes.Shipping); var dictionarExtra = orderDoc.GenericProperties.Where(x => x.PropertyType.Alias.StartsWith("extra")).ToDictionary(property => property.PropertyType.Alias, property => property.Value.ToString()); orderInfo.AddCustomerFields(dictionarExtra, CustomerDatatypes.Extra); //orderInfo.SetVATNumber(order.CustomerVATNumber); happens in AddCustomerFields var orderPaidProperty = order.Document.getProperty("orderPaid"); if (orderPaidProperty != null && orderPaidProperty.Value != null) { orderInfo.Paid = orderPaidProperty.Value == "1"; } // load data recursively from umbraco documents into order tree orderInfo.OrderLines = orderDoc.Children.Select(d => { var fields = d.GenericProperties.Where(x => !OrderedProduct.DefaultProperties.Contains(x.PropertyType.Alias)).ToDictionary(s => s.PropertyType.Alias, s => d.GetProperty <string>(s.PropertyType.Alias)); var xDoc = new XDocument(new XElement("Fields")); OrderUpdatingService.AddFieldsToXDocumentBasedOnCMSDocumentType(xDoc, fields, d.ContentType.Alias); var orderedProduct = new OrderedProduct(d.Id); var productInfo = new ProductInfo(orderedProduct, orderInfo); productInfo.ProductVariants = d.Children.Select(cd => new ProductVariantInfo(new OrderedProductVariant(cd.Id), productInfo, productInfo.Vat)).ToList(); return(new OrderLine(productInfo, orderInfo) { _customData = xDoc }); }).ToList(); // store order IO.Container.Resolve <IOrderRepository>().SaveOrderInfo(orderInfo); } // cancel does give a warning message balloon in Umbraco. //e.Cancel = true; //if (sender.ContentType.Alias != Order.NodeAlias) //{ // orderDoc.Publish(new User(0)); //} //if (orderDoc.ParentId != 0) //{ BasePage.Current.ClientTools.SyncTree(sender.Parent.Path, false); BasePage.Current.ClientTools.ChangeContentFrameUrl(string.Concat("editContent.aspx?id=", sender.Id)); //} //orderDoc.delete(); BasePage.Current.ClientTools.ShowSpeechBubble(BasePage.speechBubbleIcon.success, "Order Updated!", "This order has been updated!"); } } }
private void ContentOnAfterUpdateDocumentCache(Document sender, DocumentCacheEventArgs documentCacheEventArgs) { //if (sender.ContentType.Alias.StartsWith("uwbs") && sender.ContentType.Alias != Order.NodeAlias) //todo: work with aliasses from config var alias = sender.ContentType.Alias; // todo: make a nice way for this block if (Product.IsAlias(alias)) { ResetAll(sender.Id, alias); } else if (ProductVariant.IsAlias(alias)) { ResetAll(sender.Id, alias); } else if (Category.IsAlias(alias)) { ResetAll(sender.Id, alias); } else if (PaymentProvider.IsAlias(alias)) { ResetAll(sender.Id, alias); } else if (PaymentProviderMethod.IsAlias(alias)) { ResetAll(sender.Id, alias); } else if (DiscountProduct.IsAlias(alias)) { ResetAll(sender.Id, alias); } else if (DiscountOrder.IsAlias(alias)) { ResetAll(sender.Id, alias); } else if (ShippingProvider.IsAlias(alias)) { ResetAll(sender.Id, alias); } else if (ShippingProviderMethod.IsAlias(alias)) { ResetAll(sender.Id, alias); } else if (Store.IsAlias(alias)) { ResetAll(sender.Id, alias); } else if (alias.StartsWith("uwbs") && alias != Order.NodeAlias) { ResetAll(sender.Id, alias); } var storePickerProperty = sender.getProperty(Constants.StorePickerAlias); if (storePickerProperty != null) { int storeId; if (storePickerProperty.Value != null && int.TryParse(storePickerProperty.Value.ToString(), out storeId)) { var storeService = StoreHelper.StoreService; var storeById = storeService.GetById(storeId, null); if (storeById != null) { storeService.TriggerStoreChangedEvent(storeById); } } } if (alias.StartsWith(Settings.NodeAlias)) { IO.Container.Resolve <ISettingsService>().TriggerSettingsChangedEvent(SettingsLoader.GetSettings()); } if (alias.StartsWith(Store.NodeAlias)) { //todo: naar nieuwe v6+ API omzetten var storeService = StoreHelper.StoreService; storeService.TriggerStoreChangedEvent(storeService.GetById(sender.Id, null)); var node = new Node(sender.Id); if (!sender.Text.Equals(node.Name)) { StoreHelper.RenameStore(node.Name, sender.Text); } } }
public OrderInfo CreateOrder(Store store) { return DefaultFactoriesAndSharedFunctionality.CreateIncompleteOrderInfo(); }
private static bool GetMultiStorePropertyName(Document sender, Store store, out string propertyName) { propertyName = "url_" + store.Alias.ToLower(); if (sender.getProperty(propertyName) != null) return false; propertyName = "url_" + store.Alias.ToUpper(); if (sender.getProperty(propertyName) != null) return false; propertyName = "url_" + store.Alias; return sender.getProperty(propertyName) == null; }
internal void SetStoreUrl(Store store, string url) { _storeUrls[store] = url; }
/// <summary> /// Gets the store URL for given store. /// </summary> /// <param name="store">The store.</param> /// <returns></returns> public string GetStoreUrl(Store store) { string url; _storeUrls.TryGetValue(store, out url); return url; }