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); } } }
/// <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 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); } } }