Esempio n. 1
0
        /// <summary>
        /// Returns all the categories of the category, including any sublevel categories
        /// </summary>
        /// <param name="categoryId">The category unique identifier.</param>
        /// <param name="storeAlias">The store alias.</param>
        /// <returns></returns>
        public static List <Category> GetCategoriesRecursive(int categoryId, string storeAlias = null)
        {
            var categoryList = new List <Category>();

            GetCategoriesFromCategory(categoryList, DomainHelper.GetCategoryById(categoryId, storeAlias));
            return(categoryList);
        }
        private static void PublishedContentRequest_Prepared(object sender, EventArgs e)
        {
            var request = sender as PublishedContentRequest;

            if (request == null)
            {
                return;
            }

            var currentContent = request.PublishedContent;

            if (currentContent == null)
            {
                return;
            }

            if (ProductVariant.IsAlias(currentContent.DocumentTypeAlias) && currentContent.Parent != null)
            {
                var product = DomainHelper.GetProductById(currentContent.Parent.Id);
                if (product != null)
                {
                    UwebshopRequest.Current.Product = (IProduct)product;
                }
            }
            else if (uWebshop.Domain.Product.IsAlias(currentContent.DocumentTypeAlias))
            {
                var product = DomainHelper.GetProductById(currentContent.Id);
                if (product != null)
                {
                    UwebshopRequest.Current.Product = (IProduct)product;
                }
            }
            else if (Category.IsAlias(currentContent.DocumentTypeAlias))
            {
                var category = DomainHelper.GetCategoryById(currentContent.Id);
                if (category != null)
                {
                    UwebshopRequest.Current.Category = (ICategory)category;
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        ///     Sent an order email based on the emailNode and orderinfo
        /// </summary>
        /// <param name="emailNodeId"></param>
        /// <param name="orderInfo"></param>
        /// <param name="parameters"> </param>
        public static void SendOrderEmailCustomer(int emailNodeId, OrderInfo orderInfo, Dictionary <string, object> parameters = null)
        {
            if (emailNodeId != 0)
            {
                Log.Instance.LogDebug("SendOrderEmailCustomer emailNodeId: " + emailNodeId);
                Log.Instance.LogDebug(string.Format("SendOrderEmailCustomer orderInfo.UniqueOrderId: {0} orderInfo.OrderNumber: {1}", orderInfo.UniqueOrderId, orderInfo.OrderNumber));
                var currentCulture   = Thread.CurrentThread.CurrentCulture;
                var currentUICulture = Thread.CurrentThread.CurrentUICulture;

                Thread.CurrentThread.CurrentCulture   = orderInfo.StoreInfo.CultureInfo;
                Thread.CurrentThread.CurrentUICulture = orderInfo.StoreInfo.CultureInfo;

                var orderInfoXmlstring = DomainHelper.SerializeObjectToXmlString(orderInfo);
                var orderInfoXml       = new XmlDocument();
                orderInfoXml.LoadXml(orderInfoXmlstring);

                var email = new Email(emailNodeId);

                if (string.IsNullOrEmpty(email.Template))
                {
                    Log.Instance.LogWarning("SendOrderEmailCustomer nodeId: " + emailNodeId + " No Template Defined");

                    return;
                }

                var emailTitle = ReplaceStrings(email.Title, orderInfoXml);
                var emailText  = ReplaceStrings(email.Description, orderInfoXml);

                if (parameters == null)
                {
                    parameters = new Dictionary <string, object>();
                }
                parameters.Add("uniqueOrderId", orderInfo.UniqueOrderId.ToString());
                parameters.Add("storeAlias", orderInfo.StoreInfo.Alias);
                parameters.Add("Title", emailTitle);
                parameters.Add("Description", emailText);

                Log.Instance.LogDebug("SendOrderEmailCustomer email.Template: " + email.Template);

                string body;
                if (email.Template.EndsWith(".xslt"))
                {
                    body = IO.Container.Resolve <ICMSApplication>().RenderXsltMacro(email.Template, parameters, orderInfoXml);
                }
                else
                {
                    if (email.Template.Contains("."))
                    {
                        body = IO.Container.Resolve <ICMSApplication>().RenderMacro(email.Template, email.Id, parameters);
                    }
                    else
                    {
                        Log.Instance.LogWarning("SendOrderEmailCustomer email.Template no valid value: " + email.Template + " no email send");
                        return;
                    }
                }

                var emailTo = OrderHelper.CustomerInformationValue(orderInfo, "customerEmail");
                Log.Instance.LogDebug("SendOrderEmailCustomer emailTo: " + emailTo);
                Log.Instance.LogDebug("SendOrderEmailCustomer EmailFrom: " + orderInfo.StoreInfo.Store.EmailAddressFrom);
                Log.Instance.LogDebug("SendOrderEmailCustomer EmailFromName: " + orderInfo.StoreInfo.Store.EmailAddressFromName);
                Log.Instance.LogDebug("SendOrderEmailCustomer emailTitle: " + emailTitle);
                SendMail(orderInfo, emailTo, orderInfo.StoreInfo.Store.EmailAddressFrom, emailTitle, body, orderInfo.StoreInfo.Store.EmailAddressFromName);

                Thread.CurrentThread.CurrentCulture   = currentCulture;
                Thread.CurrentThread.CurrentUICulture = currentUICulture;
            }
            else
            {
                Log.Instance.LogError("SendOrderEmailCustomer: emailNodeId == 0");
            }
        }
 /// <summary>
 /// Gets the shipping zones.
 /// </summary>
 /// <param name="countryCode">The country code.</param>
 /// <returns></returns>
 public static List <Zone> GetShippingZones(string countryCode)
 {
     return(DomainHelper.GetObjectsByAlias <Zone>(Zone.ShippingZoneNodeAlias).Where(x => x.CountryCodes.Contains(countryCode)).ToList());
 }