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); } }
public IActionResult Post([FromBody] BrandDTO value) { BrandDTO brand = _brandService.AddBrand(value.Name); if (brand == null) { return(BadRequest()); } else { return(Ok()); } }
public void AddBrand(Brand b) { bs.AddBrand(b); }
private static void UpdateInsertProductWorker(object o) { //return; var productInStrings = (Dictionary <ProductFields.Fields, string>)o; try { bool addingNew; Product product = null; var artNo = productInStrings.ContainsKey(ProductFields.Fields.Sku) ? productInStrings[ProductFields.Fields.Sku] : string.Empty; if (string.IsNullOrEmpty(artNo)) { addingNew = true; } else { product = ProductService.GetProduct(artNo); addingNew = product == null; } if (addingNew) { product = new Product { ArtNo = string.IsNullOrEmpty(artNo) ? null : artNo }; } if (productInStrings.ContainsKey(ProductFields.Fields.Name)) { product.Name = productInStrings[ProductFields.Fields.Name]; } else { product.Name = product.Name ?? string.Empty; } if (productInStrings.ContainsKey(ProductFields.Fields.Enabled)) { product.Enabled = productInStrings[ProductFields.Fields.Enabled].Trim().Equals("+"); } if (productInStrings.ContainsKey(ProductFields.Fields.OrderByRequest)) { product.OrderByRequest = productInStrings[ProductFields.Fields.OrderByRequest].Trim().Equals("+"); } if (productInStrings.ContainsKey(ProductFields.Fields.Discount)) { product.Discount = Convert.ToDecimal(productInStrings[ProductFields.Fields.Discount]); } if (productInStrings.ContainsKey(ProductFields.Fields.Weight)) { product.Weight = Convert.ToDecimal(productInStrings[ProductFields.Fields.Weight]); } if (productInStrings.ContainsKey(ProductFields.Fields.Size)) { product.Size = GetSizeForBdFormat(productInStrings[ProductFields.Fields.Size]); } if (productInStrings.ContainsKey(ProductFields.Fields.BriefDescription)) { product.BriefDescription = productInStrings[ProductFields.Fields.BriefDescription]; } if (productInStrings.ContainsKey(ProductFields.Fields.Description)) { product.Description = productInStrings[ProductFields.Fields.Description]; } if (product.Offers.Count == 0) { product.Offers.Add(new Offer { OfferListId = CatalogService.DefaultOfferListId }); } //Changed by Evgeni to avoid updates price for on sales products if (productInStrings.ContainsKey(ProductFields.Fields.Price)) { if (product.Discount > 0 && isNeedUpdatePriceForOnSalesProductsGlobal == false) { //Update Product discount and price according to the algorithm product.Offers[0].Price = Convert.ToDecimal(productInStrings[ProductFields.Fields.Price]) / (1.000m - (product.Discount / 100)); // // Log("Product Price for " + product.ArtNo + " was not updated"); } else { product.Offers[0].Price = Convert.ToDecimal(productInStrings[ProductFields.Fields.Price]); } } if (productInStrings.ContainsKey(ProductFields.Fields.PurchasePrice)) { product.Offers[0].SupplyPrice = Convert.ToDecimal(productInStrings[ProductFields.Fields.PurchasePrice]); } if (productInStrings.ContainsKey(ProductFields.Fields.ShippingPrice)) { product.Offers[0].ShippingPrice = Convert.ToDecimal(productInStrings[ProductFields.Fields.ShippingPrice]); } if (productInStrings.ContainsKey(ProductFields.Fields.Amount)) { product.Offers[0].Amount = Convert.ToInt32(productInStrings[ProductFields.Fields.Amount]); } if (productInStrings.ContainsKey(ProductFields.Fields.Unit)) { product.Offers[0].Unit = productInStrings[ProductFields.Fields.Unit]; } if (productInStrings.ContainsKey(ProductFields.Fields.ParamSynonym)) { var prodUrl = productInStrings[ProductFields.Fields.ParamSynonym].IsNotEmpty() ? productInStrings[ProductFields.Fields.ParamSynonym] : product.ArtNo; product.UrlPath = UrlService.GetEvalibleValidUrl(product.ID, ParamType.Product, prodUrl); } else { product.UrlPath = product.UrlPath ?? UrlService.GetEvalibleValidUrl(product.ID, ParamType.Product, product.ArtNo); } if (productInStrings.ContainsKey(ProductFields.Fields.Title)) { product.Meta.Title = productInStrings[ProductFields.Fields.Title]; } else { product.Meta.Title = product.Meta.Title ?? SettingsSEO.ProductMetaTitle; } if (productInStrings.ContainsKey(ProductFields.Fields.MetaKeywords)) { product.Meta.MetaKeywords = productInStrings[ProductFields.Fields.MetaKeywords]; } else { product.Meta.MetaKeywords = product.Meta.MetaKeywords ?? SettingsSEO.ProductMetaKeywords; } if (productInStrings.ContainsKey(ProductFields.Fields.MetaDescription)) { product.Meta.MetaDescription = productInStrings[ProductFields.Fields.MetaDescription]; } else { product.Meta.MetaDescription = product.Meta.MetaDescription ?? SettingsSEO.ProductMetaDescription; } if (productInStrings.ContainsKey(ProductFields.Fields.Markers)) { ParseMarkers(product, productInStrings[ProductFields.Fields.Markers]); } if (productInStrings.ContainsKey(ProductFields.Fields.Producer)) { if (string.IsNullOrWhiteSpace(productInStrings[ProductFields.Fields.Producer])) { product.BrandId = 0; } else if (!BrandService.IsExist(productInStrings[ProductFields.Fields.Producer])) { var tempBrand = new Brand { Enabled = true, Name = productInStrings[ProductFields.Fields.Producer], Description = productInStrings[ProductFields.Fields.Producer], UrlPath = UrlService.GetEvalibleValidUrl(0, ParamType.Brand, productInStrings[ProductFields.Fields.Producer]), Meta = null }; product.BrandId = BrandService.AddBrand(tempBrand); } else { product.BrandId = BrandService.GetBrandIdByName(productInStrings[ProductFields.Fields.Producer]); } } //if (SaasDataService.IsSaasEnabled && ProductService.GetProductCountByOffer(6) >= SaasDataService.CurrentSaasData.ProductsCount) //{ // ImportStatistic.IsRun = false; //} //else //{ if (!addingNew) { ProductService.UpdateProduct(product, false); if (product.ProductId > 0) { OtherFields(productInStrings, product.ProductId); } // Log(string.Format(Resource.Admin_Import1C_Updated, product.Name, product.ArtNo)); ImportStatistic.TotalUpdateRow++; } else { if (!(SaasDataService.IsSaasEnabled && ProductService.GetProductCountByOffer(6) >= SaasDataService.CurrentSaasData.ProductsCount)) { ProductService.AddProduct(product, false); if (product.ProductId > 0) { OtherFields(productInStrings, product.ProductId); } // Log(string.Format(Resource.Admin_Import1C_Added, product.Name, product.ArtNo)); ImportStatistic.TotalAddRow++; } } //} } catch (Exception e) { ImportStatistic.TotalErrorRow++; Log(e.Message); Debug.LogError(e); } productInStrings.Clear(); ImportStatistic.RowPosition++; }