//private static String GetDeviceUrl(Device device)
        //{
        //    return "http://www.netping.ru/products/" + device.Url;
        //}
        private static void AddOffers(DeviceTreeNode offerNode, Shop shop, DeviceTreeNode childCategoryNode)
        {
            if (!(String.IsNullOrEmpty(offerNode.Device.Label.OwnNameFromPath) ||
                  offerNode.Device.Label.OwnNameFromPath.Equals("New", StringComparison.CurrentCultureIgnoreCase)))
            {
                return;
            }

            var shortDescription = offerNode.Device.Short_description;
            var descr = String.Empty;
            if (!String.IsNullOrWhiteSpace(shortDescription))
            {
                var htmlDoc = new HtmlDocument();

                htmlDoc.LoadHtml(shortDescription);
                var ulNodes = htmlDoc.DocumentNode.SelectNodes("//ul");
                if (ulNodes != null)
                {
                    foreach (var ulNode in ulNodes)
                    {
                        ulNode.Remove();
                    }
                }
                descr = htmlDoc.DocumentNode.InnerText.Replace(" ", " ");
            }

            var deviceUrl = UrlBuilder.GetDeviceUrl(offerNode.Device.Url).ToString();

            bool stock = true;
            if (offerNode.Device.DeviceStock<=0)
            {
                stock = false;
            }

            shop.Offers.Add(new Offer
            {
                Id = offerNode.Id,
                Url = deviceUrl,
                Price = (Int32)(offerNode.Device.Price.HasValue ? offerNode.Device.Price.Value : 0),
                CategoryId = childCategoryNode.Id,
                Picture = offerNode.Device.GetCoverPhoto(true).Url,
                TypePrefix = "",
                VendorCode = offerNode.Name,
                Model = offerNode.Name,
                Store = stock,
                Description = descr
            });
        }
Beispiel #2
0
 public DeviceTreeNode(DevicesTree tree, DeviceTreeNode parentNode, Device device)
 {
     _tree       = tree;
     _parentNode = parentNode;
     _device     = device;
 }
 public DeviceTreeNode(DevicesTree tree, DeviceTreeNode parentNode, Device device)
 {
     _tree = tree;
     _parentNode = parentNode;
     _device = device;
 }