Esempio n. 1
0
 private static string ProductUrl(ProductModel productModel, tbl_ProdCategories category)
 {
     return String.Format("{0}/{1}", category.tbl_SiteMap.SM_URL, productModel.ProductTitle);
 }
Esempio n. 2
0
        public ActionResult AddProduct(ProductModel productModel, SEOFieldsModel seoModel)
        {
            if (ModelState.IsValid)
            {
                var category = ECommerceService.GetProdCategoryByID(productModel.CategoryID);
                if (category == null)
                    return Json(new { success = false });
                if (WebContentService.CheckSitemapUniqueUrl(ProductUrl(productModel, category), 0, productModel.DomainID))
                    return Json(new { success = false, error = "Please change 'Title'. There is another page with the same URL already registered." });

                SiteMapType sitemapType = productModel.ProductType == ProductType.Event ? SiteMapType.EventShop : SiteMapType.ProductShop;
                tbl_SiteMap section = WebContentService.SaveSiteMap(seoModel.R301, 1, 0, productModel.DomainID, String.Empty, false, false, seoModel.Title,
                    null, "0.5", String.Empty, String.Format("{0}/{1}", category.tbl_SiteMap.SM_URL, productModel.ProductTitle), true, true, ContentType.Product, seoModel.Title,
                    category.tbl_SiteMap.SiteMapID, 0, (int)sitemapType);

                tbl_Content tContent = section != null ? WebContentService.SaveContent(String.Empty, productModel.Content, seoModel.Desc, 0, String.Empty, seoModel.Keywords, seoModel.Title,
                    seoModel.MetaData, 0, String.Empty, String.Empty, String.Empty, seoModel.Title, String.Empty, false, section.SiteMapID, 0) : null;

                tbl_Products product = ECommerceService.SaveProduct(0, productModel.CategoryID, String.Empty, DateTime.UtcNow, 1, productModel.Offer, productModel.ProductCode,
                    null, String.Empty, productModel.TaxID == 0 ? (int?)null : productModel.TaxID, productModel.ProductTitle, productModel.Live, productModel.StockControl,
                    productModel.ProductType, productModel.EventTypeID, productModel.Deliverable, productModel.Purchasable, productModel.Featured, productModel.AffiliateLink, section.SiteMapID);

                return Json(new
                {
                    success = section != null && tContent != null && product != null,
                    productID = (product != null) ?
                        product.ProductID :
                        0,
                    contentID = (tContent != null) ?
                        tContent.ContentID :
                        0
                });
            }
            return Json(new { success = false });
        }
Esempio n. 3
0
        public JsonResult ProductSettingsJson(ProductType type, int productID = 0, int contentID = 0, bool includeDeleted = false)
        {
            tbl_Content content = WebContentService.GetContentBySitemapID(productID, contentID);
            this.ViewBag.Domains = DomainService.GetAllDomainsAsSelectList((content != null) ?
                content.tbl_SiteMap.SM_DomainID : 0);
            this.ViewBag.Taxes = ECommerceService.GetAllTaxesAsSelectList((content != null) ?
                content.tbl_SiteMap.tbl_Products.P_TaxID.GetValueOrDefault(0) : 0);
            var product = new ProductModel
                {
                    CategoryID = content.tbl_SiteMap.tbl_Products.P_CategoryID.GetValueOrDefault(0),
                    Content = content.C_Content,
                    ContentID = content.ContentID,
                    DomainID = content.tbl_SiteMap.SM_DomainID,
                    Deliverable = content.tbl_SiteMap.tbl_Products.P_Deliverable,
                    Purchasable = content.tbl_SiteMap.tbl_Products.P_CanPurchase,
                    Featured = content.tbl_SiteMap.tbl_Products.P_Featured,
                    Live = content.tbl_SiteMap.tbl_Products.P_Live,
                    Offer = content.tbl_SiteMap.tbl_Products.P_Offer.GetValueOrDefault(false),
                    ProductCode = content.tbl_SiteMap.tbl_Products.P_ProductCode,
                    ProductID = content.tbl_SiteMap.tbl_Products.ProductID,
                    SitemapID = content.tbl_SiteMap.SiteMapID,
                    ProductTitle = content.tbl_SiteMap.tbl_Products.P_Title,
                    TaxID = content.tbl_SiteMap.tbl_Products.P_TaxID.GetValueOrDefault(0),
                    StockControl = content.tbl_SiteMap.tbl_Products.P_StockControl,
                    ProductType = type,
                    EventTypeID = content.tbl_SiteMap.tbl_Products.P_EventTypeID
                };
            if (type == ProductType.Event)
            {
                product.EventTypes =
                    ECommerceService.GetAllEventTypesAsSelectList((content != null) ?
                            content.tbl_SiteMap.tbl_Products.P_EventTypeID.GetValueOrDefault(0) :
                            0);
            }

            return Json(
                new ProductModel
                {
                    CategoryID = content.tbl_SiteMap.tbl_Products.P_CategoryID.GetValueOrDefault(0),
                    Content = content.C_Content,
                    ContentID = content.ContentID,
                    DomainID = content.tbl_SiteMap.SM_DomainID,
                    Deliverable = content.tbl_SiteMap.tbl_Products.P_Deliverable,
                    Purchasable = content.tbl_SiteMap.tbl_Products.P_CanPurchase,
                    Featured = content.tbl_SiteMap.tbl_Products.P_Featured,
                    Live = content.tbl_SiteMap.tbl_Products.P_Live,
                    Offer = content.tbl_SiteMap.tbl_Products.P_Offer.GetValueOrDefault(false),
                    ProductCode = content.tbl_SiteMap.tbl_Products.P_ProductCode,
                    ProductID = content.tbl_SiteMap.tbl_Products.ProductID,
                    SitemapID = content.tbl_SiteMap.SiteMapID,
                    ProductTitle = content.tbl_SiteMap.tbl_Products.P_Title,
                    TaxID = content.tbl_SiteMap.tbl_Products.P_TaxID.GetValueOrDefault(0),
                    StockControl = content.tbl_SiteMap.tbl_Products.P_StockControl,
                    ProductType = type,
                    EventTypeID = content.tbl_SiteMap.tbl_Products.P_EventTypeID
                });
        }