public static int AddBrand(Brand brand) { brand.BrandId = SQLDataHelper.GetInt(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; }
protected void Page_Load(object sender, EventArgs e) { int brandId = 0; if (!int.TryParse(Request["brandid"], out brandId) || (brand = BrandService.GetBrandById(brandId)) == null || !brand.Enabled) { Error404(); } else { divBrandSiteUrl.Visible = brand.BrandSiteUrl.IsNotEmpty(); } SetMeta(brand.Meta, brand.Name); }
public static int BrandFromString(string brand) { int brandId; if (string.IsNullOrWhiteSpace(brand)) { brandId = 0; } else if (!IsExist(brand)) { var tempBrand = new Brand { Enabled = true, Name = brand, Description = brand, UrlPath = UrlService.GetEvalibleValidUrl(0, ParamType.Brand, brand), Meta = null }; brandId = AddBrand(tempBrand); } else { brandId = GetBrandIdByName(brand); } return brandId; }
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); }
protected void CreateBrand() { try { var brand = new Brand { Name = txtName.Text, //BrandLogo = logo, Description = FCKDescription.Text, BriefDescription = FCKBriefDescription.Text, Enabled = chkEnabled.Checked, UrlPath = txtURL.Text, SortOrder = txtSortOrder.Text.TryParseInt(), CountryId = SQLDataHelper.GetInt(ddlCountry.SelectedValue), BrandSiteUrl = txtBrandSiteUrl.Text, Meta = new MetaInfo { Type = MetaType.Brand, MetaDescription = txtMetaDescription.Text, Title = txtHeadTitle.Text, MetaKeywords = txtMetaKeys.Text, H1 = txtH1.Text } }; var tempbrandId = BrandService.AddBrand(brand); if (FileUpload1.HasFile) { var tempName = PhotoService.AddPhoto(new Photo(0, tempbrandId, PhotoType.Brand) { OriginName = FileUpload1.FileName }); if (!string.IsNullOrWhiteSpace(tempName)) { using (Image image = Image.FromStream(FileUpload1.FileContent)) { FileHelpers.SaveResizePhotoFile(FoldersHelper.GetPathAbsolut(FolderType.BrandLogo, tempName), SettingsPictureSize.BrandLogoWidth, SettingsPictureSize.BrandLogoHeight, image); } } } if (lblError.Visible == false) { txtName.Text = string.Empty; FCKDescription.Text = string.Empty; FCKBriefDescription.Text = string.Empty; chkEnabled.Checked = true; } // close } catch (Exception ex) { MsgErr(ex.Message + " CreateBrand main"); Debug.LogError(ex); } }
protected void Page_Load(object sender, EventArgs e) { if (ProductId == 0) { Error404(); return; } //if not have category if (ProductService.GetCountOfCategoriesByProductId(ProductId) == 0) { Error404(); return; } // --- Check product exist ------------------------ CurrentProduct = ProductService.GetProduct(ProductId); if (CurrentProduct == null || CurrentProduct.Enabled == false || CurrentProduct.CategoryEnabled == false) { Error404(); return; } CurrentOffer = CurrentProduct.Offers.FirstOrDefault(o => o.Main) ?? CurrentProduct.Offers.FirstOrDefault(); btnAdd.Text = SettingsCatalog.BuyButtonText; btnOrderByRequest.Text = SettingsCatalog.PreOrderButtonText; sizeColorPicker.ProductId = ProductId; rating.ProductId = CurrentProduct.ID; rating.Rating = CurrentProduct.Ratio; rating.ShowRating = SettingsCatalog.EnableProductRating; rating.ReadOnly = RatingService.DoesUserVote(ProductId, CustomerSession.CustomerId); CurrentBrand = CurrentProduct.Brand; productPropertiesView.ProductId = ProductId; productPhotoView.Product = CurrentProduct; RecentlyViewService.SetRecentlyView(CustomerSession.CustomerId, ProductId); SetMeta(CurrentProduct.Meta, CurrentProduct.Name, CategoryService.GetCategory(CurrentProduct.CategoryID).Name, CurrentProduct.Brand != null ? CurrentProduct.Brand.Name : string.Empty); productReviews.EntityType = EntityType.Product; productReviews.EntityId = ProductId; ltrlRightColumnModules.Text = ModulesRenderer.RenderDetailsModulesToRightColumn(); breadCrumbs.Items = CategoryService.GetParentCategories(CurrentProduct.CategoryID).Reverse().Select(cat => new BreadCrumbs { Name = cat.Name, Url = UrlService.GetLink(ParamType.Category, cat.UrlPath, cat.ID) }).ToList(); breadCrumbs.Items.Insert(0, new BreadCrumbs { Name = Resource.Client_MasterPage_MainPage, Url = UrlService.GetAbsoluteLink("/") }); breadCrumbs.Items.Add(new BreadCrumbs { Name = CurrentProduct.Name, Url = null }); }
private void LoadBrand() { int brandId = 0; if (!int.TryParse(Request["brandid"], out brandId) || (brand = BrandService.GetBrandById(brandId)) == null || !brand.Enabled) { Error404(); } else { divBrandSiteUrl.Visible = brand.BrandSiteUrl.IsNotEmpty(); var sb = new StringBuilder(); var avalibleCategories = BrandService.GetCategoriesByBrand(brandId); foreach ( var category in CategoryService.GetChildCategoriesByCategoryId(0, false) .Where(cat => avalibleCategories.ContainsKey(cat.CategoryId))) { sb.AppendFormat("<div class=\"block-uc brand-block\">"); string link = UrlService.GetLink(ParamType.Category, category.UrlPath, category.CategoryId); if (link.Contains("?")) { link = QueryHelper.ChangeQueryParam(link, "brand", brandId.ToString()); link = QueryHelper.ChangeQueryParam(link, "indepth", "1"); } else { link += "?" + QueryHelper.CreateQueryString(new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>("brand", brandId.ToString()), new KeyValuePair<string, string>("indepth", "1") }); } sb.AppendFormat("<span class=\"title\"><a href='{0}'>{1} ({2})</a></span>", link, category.Name, avalibleCategories[category.CategoryId].InChildsCategoryCount); sb.AppendFormat("<div class=\"content list-brand-marker\">"); foreach ( var child in category.ChildCategories.Where(ch => avalibleCategories.ContainsKey(ch.CategoryId)) ) { string sublink = UrlService.GetLink(ParamType.Category, child.UrlPath, child.CategoryId); if (sublink.Contains("?")) { sublink = QueryHelper.ChangeQueryParam(sublink, "brand", brandId.ToString()); sublink = QueryHelper.ChangeQueryParam(sublink, "indepth", "1"); } else { sublink += "?" + QueryHelper.CreateQueryString(new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>("brand", brandId.ToString()), new KeyValuePair<string, string>("indepth", "1") }); } sb.AppendFormat("<a href='{0}'>{1} ({2})</a>", sublink, child.Name, avalibleCategories[child.CategoryId].InChildsCategoryCount); } sb.AppendFormat("</div>"); sb.AppendFormat("</div>"); } lCategories.Text = sb.ToString(); } }