public static int AddBrand(Brand brand) { brand.BrandId = Convert.ToInt32(SQLDataAccess.ExecuteScalar( "[Catalog].[sp_AddBrand]", CommandType.StoredProcedure, new SqlParameter("@BrandName", brand.Name), new SqlParameter("@BrandDescription", brand.Description ?? (object)DBNull.Value), new SqlParameter("@BrandBriefDescription", brand.BriefDescription ?? (object)DBNull.Value), new SqlParameter("@Enabled", brand.Enabled), new SqlParameter("@SortOrder", brand.SortOrder), new SqlParameter("@CountryID", brand.CountryId == 0 ? (object)DBNull.Value : brand.CountryId), new SqlParameter("@UrlPath", brand.UrlPath), new SqlParameter("@BrandSiteUrl", brand.BrandSiteUrl.IsNotEmpty() ? brand.BrandSiteUrl : (object)DBNull.Value) )); if (brand.BrandId == 0) return 0; // ---- Meta if (brand.Meta != null) { brand.Meta.ObjId = brand.BrandId; MetaInfoService.SetMeta(brand.Meta); } return brand.BrandId; }
/// <summary> /// add category /// </summary> /// <param name="category"></param> /// <param name="updateCache"></param> /// <param name="setHierarchicallyEnabled"></param> /// <returns></returns> public static int AddCategory(Category category, bool updateCache, bool setHierarchicallyEnabled = true) { int id; using (var db = new SQLDataAccess()) { id = AddCategory(category, updateCache, db); if (id == -1) { return(-1); } // ---- Meta if (setHierarchicallyEnabled) { SetCategoryHierarchicallyEnabled(id); } if (category.Meta != null) { if (!category.Meta.Title.IsNullOrEmpty() || !category.Meta.MetaKeywords.IsNullOrEmpty() || !category.Meta.MetaDescription.IsNullOrEmpty() || !category.Meta.H1.IsNullOrEmpty()) { category.Meta.ObjId = id; MetaInfoService.SetMeta(category.Meta); } } } return(id); }
public static int InsertNews(NewsItem news) { CacheManager.Remove(CacheNames.GetNewsForMainPage()); var id = SQLDataAccess.ExecuteScalar <int>("[Settings].[sp_AddNews]", CommandType.StoredProcedure, new[] { new SqlParameter("@NewsCategoryID", news.NewsCategoryID), new SqlParameter("@AddingDate", news.AddingDate), new SqlParameter("@Title", news.Title), //new SqlParameter("@Picture", news.Picture), new SqlParameter("@TextToPublication", news.TextToPublication), new SqlParameter("@TextToEmail", news.TextToEmail), new SqlParameter("@TextAnnotation", news.TextAnnotation), new SqlParameter("@ShowOnMainPage", news.ShowOnMainPage), new SqlParameter("@UrlPath", news.UrlPath) }); // ---- Meta if (news.Meta != null) { if (!news.Meta.Title.IsNullOrEmpty() || !news.Meta.MetaKeywords.IsNullOrEmpty() || !news.Meta.MetaDescription.IsNullOrEmpty() || !news.Meta.H1.IsNullOrEmpty()) { news.Meta.ObjId = id; MetaInfoService.SetMeta(news.Meta); } } return(id); }
public static bool UpdateNews(NewsItem news) { CacheManager.Remove(CacheNames.GetNewsForMainPage()); SQLDataAccess.ExecuteNonQuery("[Settings].[sp_UpdateNews]", CommandType.StoredProcedure, new[] { new SqlParameter("@NewsID", news.NewsID), new SqlParameter("@NewsCategoryID", news.NewsCategoryID), new SqlParameter("@AddingDate", news.AddingDate), new SqlParameter("@Title", news.Title), //new SqlParameter("@Picture", news.Picture), new SqlParameter("@TextToPublication", news.TextToPublication), new SqlParameter("@TextToEmail", news.TextToEmail), new SqlParameter("@TextAnnotation", news.TextAnnotation), new SqlParameter("@ShowOnMainPage", news.ShowOnMainPage), new SqlParameter("@UrlPath", news.UrlPath) } ); if (news.Meta != null) { if (news.Meta.Title.IsNullOrEmpty() && news.Meta.MetaKeywords.IsNullOrEmpty() && news.Meta.MetaDescription.IsNullOrEmpty() && news.Meta.H1.IsNullOrEmpty()) { if (MetaInfoService.IsMetaExist(news.ID, MetaType.News)) { MetaInfoService.DeleteMetaInfo(news.ID, MetaType.News); } } else { MetaInfoService.SetMeta(news.Meta); } } return(true); }
public static void UpdateStaticPage(StaticPage page) { SQLDataAccess.ExecuteNonQuery( @"UPDATE [CMS].[StaticPage] SET [PageName] = @PageName, [PageText] = @PageText, [SortOrder] = @SortOrder, [ModifyDate] = GETDATE(), [IndexAtSiteMap] = @IndexAtSiteMap, [ParentID] = @ParentID, [Enabled] = @Enabled, UrlPath=@UrlPath WHERE [StaticPageID] = @StaticPageID", CommandType.Text, new[] { new SqlParameter("@PageName", page.PageName), new SqlParameter("@PageText", page.PageText), new SqlParameter("@SortOrder", page.SortOrder), new SqlParameter("@IndexAtSiteMap", page.IndexAtSiteMap), new SqlParameter("@ParentID", page.ParentId == 0 ? DBNull.Value : (object)page.ParentId), new SqlParameter("@StaticPageID", page.StaticPageId), new SqlParameter("@Enabled", page.Enabled), new SqlParameter("@UrlPath", page.UrlPath) }); // ---- Meta if (page.Meta != null) { if (page.Meta.Title.IsNullOrEmpty() && page.Meta.MetaKeywords.IsNullOrEmpty() && page.Meta.MetaDescription.IsNullOrEmpty()) { if (MetaInfoService.IsMetaExist(page.ID, MetaType.StaticPage)) { MetaInfoService.DeleteMetaInfo(page.ID, MetaType.StaticPage); } } else { MetaInfoService.SetMeta(page.Meta); } } }
public static int AddStaticPage(StaticPage page) { var id = SQLDataAccess.ExecuteScalar <int>(@"INSERT INTO [CMS].[StaticPage] ([PageName],[PageText],[SortOrder],[AddDate],[ModifyDate],[IndexAtSiteMap],[ParentID],[Enabled],[UrlPath]) VALUES " + " (@PageName,@PageText,@SortOrder,GETDATE(),GETDATE(),@IndexAtSiteMap,@ParentID,@Enabled, @UrlPath); SELECT scope_identity();", CommandType.Text, new[] { new SqlParameter("@PageName", page.PageName ?? ""), new SqlParameter("@PageText", page.PageText ?? ""), new SqlParameter("@SortOrder", page.SortOrder), new SqlParameter("@IndexAtSiteMap", page.IndexAtSiteMap), new SqlParameter("@Enabled", page.Enabled), page.ParentId == 0 ? new SqlParameter("@ParentID", DBNull.Value) : new SqlParameter("@ParentID", page.ParentId), new SqlParameter("@UrlPath", page.UrlPath) } ); // ---- Meta if (page.Meta != null) { if (!page.Meta.Title.IsNullOrEmpty() || !page.Meta.MetaKeywords.IsNullOrEmpty() || !page.Meta.MetaDescription.IsNullOrEmpty()) { page.Meta.ObjId = id; MetaInfoService.SetMeta(page.Meta); } } return(id); }
/// <summary> /// update product /// </summary> /// <param name="product"></param> /// <param name="sentToLuceneIndex"></param> /// <param name="db"></param> /// <returns></returns> public static bool UpdateProduct(Product product, bool sentToLuceneIndex, SQLDataAccess db) { db.cmd.CommandText = "[Catalog].[sp_UpdateProductById]"; db.cmd.CommandType = CommandType.StoredProcedure; db.cmd.Parameters.Clear(); db.cmd.Parameters.AddWithValue("@ArtNo", product.ArtNo); db.cmd.Parameters.AddWithValue("@Name", product.Name); db.cmd.Parameters.AddWithValue("@ProductID", product.ProductId); db.cmd.Parameters.AddWithValue("@Ratio", product.Ratio); db.cmd.Parameters.AddWithValue("@Discount", product.Discount); db.cmd.Parameters.AddWithValue("@Weight", product.Weight); db.cmd.Parameters.AddWithValue("@Size", (product.Size ?? ((object)DBNull.Value))); db.cmd.Parameters.AddWithValue("@IsFreeShipping", product.IsFreeShipping); db.cmd.Parameters.AddWithValue("@ItemsSold", product.ItemsSold); db.cmd.Parameters.AddWithValue("@BriefDescription", (product.BriefDescription ?? ((object)DBNull.Value))); db.cmd.Parameters.AddWithValue("@Description", (product.Description ?? ((object)DBNull.Value))); db.cmd.Parameters.AddWithValue("@Enabled", product.Enabled); db.cmd.Parameters.AddWithValue("@OrderByRequest", product.OrderByRequest); db.cmd.Parameters.AddWithValue("@Recomended", product.Recomended); db.cmd.Parameters.AddWithValue("@New", product.New); db.cmd.Parameters.AddWithValue("@BestSeller", product.BestSeller); db.cmd.Parameters.AddWithValue("@OnSale", product.OnSale); db.cmd.Parameters.AddWithValue("@BrandID", product.BrandId == 0 ? ((object)DBNull.Value) : product.BrandId); db.cmd.Parameters.AddWithValue("@UrlPath", product.UrlPath); db.cmd.ExecuteNonQuery(); SetProductHierarchicallyEnabled(product.ProductId); if (product.Offers != null && product.Offers.Count > 0) { OfferService.UpdateOffersByProductId(product.ProductId, product.Offers); } if (product.Meta != null) { if (product.Meta.Title.IsNullOrEmpty() && product.Meta.MetaKeywords.IsNullOrEmpty() && product.Meta.MetaDescription.IsNullOrEmpty()) { if (MetaInfoService.IsMetaExist(product.ProductId, MetaType.Product)) { MetaInfoService.DeleteMetaInfo(product.ProductId, MetaType.Product); } } else { MetaInfoService.SetMeta(product.Meta); } } if (sentToLuceneIndex) { LuceneSearch.AddUpdateLuceneIndex(new SampleData(product.ProductId, product.ArtNo, product.Name)); } return(true); }
/// <summary> /// update category /// </summary> /// <param name="category"></param> /// <param name="updateCache">refresh cache</param> /// <returns></returns> public static bool UpdateCategory(Category category, bool updateCache) { SQLDataAccess.ExecuteNonQuery("[Catalog].[sp_UpdateCategory]", CommandType.StoredProcedure, new SqlParameter("@CategoryID", category.CategoryId), new SqlParameter("@Name", category.Name), new SqlParameter("@ParentCategory", category.ParentCategoryId), new SqlParameter("@Description", category.Description), new SqlParameter("@BriefDescription", category.BriefDescription), new SqlParameter("@Enabled", category.Enabled), new SqlParameter("@DisplayStyle", category.DisplayStyle), new SqlParameter("@displayChildProducts", category.DisplayChildProducts), new SqlParameter("@DisplayBrandsInMenu", category.DisplayBrandsInMenu), new SqlParameter("@DisplaySubCategoriesInMenu", category.DisplaySubCategoriesInMenu), new SqlParameter("@SortOrder", category.SortOrder), //new SqlParameter("@Picture", !string.IsNullOrEmpty(category.Picture) ? category.Picture : ((object)DBNull.Value)), //new SqlParameter("@MiniPicture", !string.IsNullOrEmpty(category.MiniPicture) ? category.MiniPicture : ((object)DBNull.Value)), new SqlParameter("@UrlPath", category.UrlPath), new SqlParameter("@Sorting", category.Sorting) ); if (category.Meta != null) { if (category.Meta.Title.IsNullOrEmpty() && category.Meta.MetaKeywords.IsNullOrEmpty() && category.Meta.MetaDescription.IsNullOrEmpty() && category.Meta.H1.IsNullOrEmpty()) { if (MetaInfoService.IsMetaExist(category.CategoryId, MetaType.Category)) { MetaInfoService.DeleteMetaInfo(category.CategoryId, MetaType.Category); } } else { MetaInfoService.SetMeta(category.Meta); } } SetCategoryHierarchicallyEnabled(category.CategoryId); // Work with cache if (updateCache) { CacheManager.Remove(CacheNames.GetCategoryCacheObjectName(category.CategoryId)); CacheManager.RemoveByPattern("MenuCatalog"); if (category.ParentCategoryId == 0) { var cacheName = CacheNames.GetBottomMenuCacheObjectName(); if (CacheManager.Contains(cacheName)) { CacheManager.Remove(cacheName); } } } return(true); }
public string UpdateProductMeta(int productID, MetaInfo meta) { if (!AuthorizeService.CheckAdminCookies()) { return(MsgAuthFailed); } Product p = ProductService.GetProduct(productID); if (p == null) { return(string.Format(MsgNotFound, productID)); } p.Meta = meta; MetaInfoService.SetMeta(p.Meta); return(string.Format(MsgUpdateSuccess, productID)); }
public static int InsertNewsCategory(NewsCategory newsCategory) { var id = SQLDataAccess.ExecuteScalar <int>("Insert into [Settings].[NewsCategory] ([Name],[SortOrder],[UrlPath]) values (@Name,@SortOrder,@UrlPath); Select SCOPE_IDENTITY ();", CommandType.Text, new SqlParameter("@Name", newsCategory.Name), new SqlParameter("@UrlPath", newsCategory.UrlPath), new SqlParameter("@SortOrder", newsCategory.SortOrder)); if (newsCategory.Meta != null) { if (!newsCategory.Meta.Title.IsNullOrEmpty() || !newsCategory.Meta.MetaKeywords.IsNullOrEmpty() || !newsCategory.Meta.MetaDescription.IsNullOrEmpty() || !newsCategory.Meta.H1.IsNullOrEmpty()) { newsCategory.Meta.ObjId = id; MetaInfoService.SetMeta(newsCategory.Meta); } } return(id); }
public static void UpdateBrand(Brand brand) { SQLDataAccess.ExecuteNonQuery( "[Catalog].[sp_UpdateBrandById]", CommandType.StoredProcedure, new SqlParameter("@BrandID", brand.BrandId), new SqlParameter("@BrandName", brand.Name), new SqlParameter("@BrandDescription", brand.Description ?? (object)DBNull.Value), new SqlParameter("@BrandBriefDescription", brand.BriefDescription ?? (object)DBNull.Value), new SqlParameter("@Enabled", brand.Enabled), new SqlParameter("@SortOrder", brand.SortOrder), new SqlParameter("@CountryID", brand.CountryId == 0 ? (object)DBNull.Value : brand.CountryId), new SqlParameter("@UrlPath", brand.UrlPath), new SqlParameter("@BrandSiteUrl", brand.BrandSiteUrl.IsNotEmpty() ? brand.BrandSiteUrl : (object)DBNull.Value) ); MetaInfoService.SetMeta(brand.Meta); }
public static void UpdateNewsCategory(NewsCategory newsCategory) { SQLDataAccess.ExecuteNonQuery("Update [Settings].[NewsCategory] set [Name]=@name,[UrlPath] = @UrlPath , [SortOrder] = @SortOrder where NewsCategoryID = @NewsCategoryID", CommandType.Text, new SqlParameter("@NewsCategoryID", newsCategory.NewsCategoryID), new SqlParameter("@Name", newsCategory.Name), new SqlParameter("@UrlPath", newsCategory.UrlPath), new SqlParameter("@SortOrder", newsCategory.SortOrder)); if (newsCategory.Meta != null) { if (newsCategory.Meta.Title.IsNullOrEmpty() && newsCategory.Meta.MetaKeywords.IsNullOrEmpty() && newsCategory.Meta.MetaDescription.IsNullOrEmpty() && newsCategory.Meta.H1.IsNullOrEmpty()) { if (MetaInfoService.IsMetaExist(newsCategory.NewsCategoryID, MetaType.NewsCategory)) { MetaInfoService.DeleteMetaInfo(newsCategory.NewsCategoryID, MetaType.NewsCategory); } } else { MetaInfoService.SetMeta(newsCategory.Meta); } } }
public static void Update(string name, MetaInfo metaInfo) { var query = string.Empty; switch (metaInfo.Type) { case MetaType.Brand: query = "UPDATE Catalog.Brand SET BrandName=@name Where BrandID=@objId"; break; case MetaType.Category: query = "UPDATE [Catalog].[Category] SET [Name] = @name WHERE CategoryID = @objId"; break; case MetaType.News: query = "UPDATE [Settings].[News] SET [Title] = @name WHERE NewsID = @objId"; break; case MetaType.Product: query = "UPDATE [Catalog].[Product] SET [Name] = @name WHERE [ProductID] = @objId"; break; case MetaType.StaticPage: query = "UPDATE [CMS].[StaticPage] SET [PageName] = @name WHERE [StaticPageID] = @objId"; break; } SQLDataAccess.ExecuteNonQuery(query, CommandType.Text, new SqlParameter("@name", name), new SqlParameter("@objId", metaInfo.ObjId)); if (MetaType.Category == metaInfo.Type) { CategoryService.ClearCategoryCache(); } MetaInfoService.SetMeta(metaInfo); }
/// <summary> /// add product /// </summary> /// <param name="product"></param> /// <param name="sentToLuceneIndex"></param> /// <returns></returns> public static int AddProduct(Product product, bool sentToLuceneIndex) { if (SaasDataService.IsSaasEnabled && GetProductCountByOffer(6) >= SaasDataService.CurrentSaasData.ProductsCount) { return(0); } product.ProductId = Convert.ToInt32(SQLDataAccess.ExecuteScalar("[Catalog].[sp_AddProduct]", CommandType.StoredProcedure, new SqlParameter("@ArtNo", product.ArtNo), new SqlParameter("@Name", product.Name), new SqlParameter("@Ratio", product.Ratio), new SqlParameter("@Discount", product.Discount), new SqlParameter("@Weight", product.Weight), new SqlParameter("@Size", (product.Size ?? ((object)DBNull.Value))), new SqlParameter("@IsFreeShipping", product.IsFreeShipping), new SqlParameter("@ItemsSold", product.ItemsSold), new SqlParameter("@BriefDescription", (product.BriefDescription ?? ((object)DBNull.Value))), new SqlParameter("@Description", (product.Description ?? ((object)DBNull.Value))), new SqlParameter("@Enabled", product.Enabled), new SqlParameter("@Recomended", product.Recomended), new SqlParameter("@New", product.New), new SqlParameter("@BestSeller", product.BestSeller), new SqlParameter("@OnSale", product.OnSale), new SqlParameter("@OrderByRequest", product.OrderByRequest), new SqlParameter("@BrandID", (product.BrandId != 0 ? product.BrandId : (object)DBNull.Value)), new SqlParameter("@UrlPath", product.UrlPath) )); if (product.ProductId == 0) { return(0); } //by default in bd set ID if artNo is Null if (string.IsNullOrEmpty(product.ArtNo)) { product.ArtNo = product.ProductId.ToString(CultureInfo.InvariantCulture); } SetProductHierarchicallyEnabled(product.ProductId); // ---- Offers if (product.Offers != null && product.Offers.Count != 0) { OfferService.AddOffersToProduct(product.ProductId, product.Offers.Where(o => o.OfferId == 0)); } // ---- Meta if (product.Meta != null) { if (!product.Meta.Title.IsNullOrEmpty() || !product.Meta.MetaKeywords.IsNullOrEmpty() || !product.Meta.MetaDescription.IsNullOrEmpty()) { product.Meta.ObjId = product.ProductId; MetaInfoService.SetMeta(product.Meta); } } if (sentToLuceneIndex) { LuceneSearch.AddUpdateLuceneIndex(new SampleData(product.ProductId, product.ArtNo, product.Name)); } return(product.ProductId); }