Ejemplo n.º 1
0
        public ActionResult YandexMarket()
        {
            var xml = MethodBase.GetCurrentMethod().CacheDay(() =>
                                                             YmlGenerator.Get(Url).ToString());

            return(new XmlResult(xml));
        }
Ejemplo n.º 2
0
        public void GenerateYml()
        {
            var catalog = new YmlCatalog
            {
                Date = DateTime.Now
            };
            var shop = new Shop();

            catalog.Shop = shop;


            const String netpingRu = "Netping.ru";

            shop.Name    = netpingRu;
            shop.Company = netpingRu;
            shop.Url     = "http://www.netping.ru";
            shop.Currencies.Add(new Currency
            {
                Id   = "RUR",
                Rate = 1,
                Plus = 0
            });

            var tree = new DevicesTree(_dataRepository.Devices);

            foreach (var categoryNode in tree.Nodes)
            {
                shop.Categories.Add(new Category
                {
                    Id       = categoryNode.Id,
                    Name     = categoryNode.Name,
                    ParentId = categoryNode.Parent == null ? (Int32?)null : categoryNode.Parent.Id
                });

                foreach (var childCategoryNode in categoryNode.Nodes)
                {
                    AddOffers(childCategoryNode, shop, categoryNode);
                }
            }

            shop.LocalDeliveryCost = 0;

            YmlGenerator.Generate(catalog, StaticFilePaths.CatalogFilePath);
        }