public ProductDto PrepareProductDTO(Product product) { var productDto = product.ToDto(); var productPictures = _productService.GetProductPicturesByProductId(product.Id); PrepareProductImages(productPictures, productDto); var x = productDto.SeName = _urlRecordService.GetSeName(product); productDto.DiscountIds = _discountService.GetAppliedDiscounts(product).Select(discount => discount.Id).ToList(); productDto.ManufacturerIds = _manufacturerService.GetProductManufacturersByProductId(product.Id).Select(pm => pm.Id).ToList(); productDto.RoleIds = _aclService.GetAclRecords(product).Select(acl => acl.CustomerRoleId).ToList(); productDto.StoreIds = _storeMappingService.GetStoreMappings(product).Select(mapping => mapping.StoreId) .ToList(); productDto.Tags = _productTagService.GetAllProductTagsByProductId(product.Id).Select(tag => tag.Name) .ToList(); productDto.AssociatedProductIds = GetRelatedProductIdsByProductId(product.Id); // load product attributes var productAttributeMappings = _productAttributeService .GetProductAttributeMappingsByProductId(product.Id); PrepareProductAttributes(productAttributeMappings, productDto); // load product specification attributes var productSpecificationAttributeMappings = _specificationAttributeService .GetProductSpecificationAttributes(productId: product.Id); PrepareProductSpecificationAttributes(productSpecificationAttributeMappings, productDto); var allLanguages = _languageService.GetAllLanguages(); productDto.LocalizedNames = new List <LocalizedNameDto>(); foreach (var language in allLanguages) { var localizedNameDto = new LocalizedNameDto { LanguageId = language.Id, LocalizedName = _localizationService.GetLocalized(product, x => x.Name, language.Id) }; productDto.LocalizedNames.Add(localizedNameDto); } return(productDto); }
private ProductDetailsModel GetProductDetails(int productId, int updateCartItemId = 0) { var controllerContext = new ControllerContext(); var product = _productService.GetProductById(productId); var cart = _workContext.CurrentCustomer.ShoppingCartItems .LimitPerStore(_storeContext.CurrentStore.Id).ToList(); var updatecartitem = cart.FirstOrDefault(x => x.Id == updateCartItemId); var model = _productModelFactory.PrepareProductDetailsModel(product, updatecartitem, false); // add hidden specification params // which checked as "don't show on product page" model.ProductSpecifications = _specificationAttributeService.GetProductSpecificationAttributes(productId, 0, null, null) .Select(psa => { var m = new ProductSpecificationModel { SpecificationAttributeId = psa.SpecificationAttributeOption.SpecificationAttributeId, SpecificationAttributeName = psa.SpecificationAttributeOption.SpecificationAttribute .GetLocalized(x => x.Name), ColorSquaresRgb = psa.SpecificationAttributeOption.ColorSquaresRgb }; switch (psa.AttributeType) { case SpecificationAttributeType.Option: m.ValueRaw = WebUtility.HtmlEncode(psa.SpecificationAttributeOption.GetLocalized(x => x.Name)); break; case SpecificationAttributeType.CustomText: m.ValueRaw = WebUtility.HtmlEncode(psa.CustomValue); break; case SpecificationAttributeType.CustomHtmlText: m.ValueRaw = psa.CustomValue; break; case SpecificationAttributeType.Hyperlink: m.ValueRaw = string.Format("<a href='{0}' target='_blank'>{0}</a>", psa.CustomValue); break; default: break; } return(m); }) .ToList(); return(model); }
public JsonResult GetSpecAttributes(int productId) { try { var specificationAttributes = _specificationAttributeService.GetProductSpecificationAttributes(productId); var list = new List <dynamic>(); foreach (var spec in specificationAttributes) { dynamic attr = new { name = spec.SpecificationAttributeOption.SpecificationAttribute.Name, value = spec.CustomValue }; list.Add(attr); } return(Json(new { status = "success", data = list })); } catch (Exception ex) { return(Json(new { status = "error", message = ex.Message })); } }
public static IList <ProductSpecificationModel> PrepareProductSpecificationModel(this Controller controller, IWorkContext workContext, ISpecificationAttributeService specificationAttributeService, ICacheManager cacheManager, Product product) { if (product == null) { throw new ArgumentNullException("product"); } string cacheKey = string.Format(ModelCacheEventConsumer.PRODUCT_SPECS_MODEL_KEY, product.Id, workContext.WorkingLanguage.Id); return(cacheManager.Get(cacheKey, () => specificationAttributeService.GetProductSpecificationAttributes(product.Id, 0, null, true) .Select(psa => { var m = new ProductSpecificationModel { SpecificationAttributeId = psa.SpecificationAttributeOption.SpecificationAttributeId, SpecificationAttributeName = psa.SpecificationAttributeOption.SpecificationAttribute.GetLocalized(x => x.Name), ColorSquaresRgb = psa.SpecificationAttributeOption.ColorSquaresRgb }; switch (psa.AttributeType) { case SpecificationAttributeType.Option: m.ValueRaw = HttpUtility.HtmlEncode(psa.SpecificationAttributeOption.GetLocalized(x => x.Name)); break; case SpecificationAttributeType.CustomText: m.ValueRaw = HttpUtility.HtmlEncode(psa.CustomValue); break; case SpecificationAttributeType.CustomHtmlText: m.ValueRaw = psa.CustomValue; break; case SpecificationAttributeType.Hyperlink: m.ValueRaw = string.Format("<a href='{0}' target='_blank'>{0}</a>", psa.CustomValue); break; default: break; } return m; }).ToList() )); }
/// <summary> /// Copy product specifications /// </summary> /// <param name="product">Product</param> /// <param name="productCopy">New product</param> protected virtual void CopyProductSpecifications(Product product, Product productCopy) { foreach (var productSpecificationAttribute in _specificationAttributeService.GetProductSpecificationAttributes(product.Id)) { var psaCopy = new ProductSpecificationAttribute { ProductId = productCopy.Id, AttributeTypeId = productSpecificationAttribute.AttributeTypeId, SpecificationAttributeOptionId = productSpecificationAttribute.SpecificationAttributeOptionId, CustomValue = productSpecificationAttribute.CustomValue, AllowFiltering = productSpecificationAttribute.AllowFiltering, ShowOnProductPage = productSpecificationAttribute.ShowOnProductPage, DisplayOrder = productSpecificationAttribute.DisplayOrder }; _specificationAttributeService.InsertProductSpecificationAttribute(psaCopy); } }
public static IList<ProductSpecificationModel> PrepareProductSpecificationModel(this Controller controller, IWorkContext workContext, ISpecificationAttributeService specificationAttributeService, ICacheManager cacheManager, Product product) { if (product == null) throw new ArgumentNullException("product"); string cacheKey = string.Format(ModelCacheEventConsumer.PRODUCT_SPECS_MODEL_KEY, product.Id, workContext.WorkingLanguage.Id); return cacheManager.Get(cacheKey, () => specificationAttributeService.GetProductSpecificationAttributes(product.Id, 0, null, true) .Select(psa => { var m = new ProductSpecificationModel { SpecificationAttributeId = psa.SpecificationAttributeOption.SpecificationAttributeId, SpecificationAttributeName = psa.SpecificationAttributeOption.SpecificationAttribute.GetLocalized(x => x.Name), ColorSquaresRgb = psa.SpecificationAttributeOption.ColorSquaresRgb }; switch (psa.AttributeType) { case SpecificationAttributeType.Option: m.ValueRaw = HttpUtility.HtmlEncode(psa.SpecificationAttributeOption.GetLocalized(x => x.Name)); break; case SpecificationAttributeType.CustomText: m.ValueRaw = HttpUtility.HtmlEncode(psa.CustomValue); break; case SpecificationAttributeType.CustomHtmlText: m.ValueRaw = psa.CustomValue; break; case SpecificationAttributeType.Hyperlink: m.ValueRaw = string.Format("<a href='{0}' target='_blank'>{0}</a>", psa.CustomValue); break; default: break; } return m; }).ToList() ); }
private string ProductAdminTabString(int productId, IHtmlHelper helper) { var settings = _settingService.LoadSetting <CcSettings>(); var specAttrs = _specificationAttributeService.GetProductSpecificationAttributes(productId); var editorName = ""; var editorSpecAttr = specAttrs.FirstOrDefault(x => x.SpecificationAttributeOption.SpecificationAttributeId == settings.EditorDefinitionSpecificationAttributeId); if (editorSpecAttr != null) { editorName = editorSpecAttr.CustomValue; } var configName = ""; var configSpecattr = specAttrs.FirstOrDefault(x => x.SpecificationAttributeOption.SpecificationAttributeId == settings.EditorConfigurationSpecificationAttributeId); if (configSpecattr != null) { configName = configSpecattr.CustomValue; } var model = new CcProductSetting { ProductId = productId, EditorSpecAttrId = settings.EditorDefinitionSpecificationAttributeId, EditorSpecAttrOptionId = settings.EditorDefinitionSpecificationOptionId, EditorConfigSpecAttrId = settings.EditorConfigurationSpecificationAttributeId, EditorConfigSpecAttrOptionId = settings.EditorConfigurationSpecificationOptionId, EditorList = _ccService.GetAllEditors(), EditorName = editorName, ConfigName = configName, CcUrl = settings.ServerHostUrl }; var tabContent = helper.Partial("~/Plugins/Widgets.CustomersCanvas/Views/Product/ProductAdminTab.cshtml", model).RenderHtmlContent(); tabContent = JavaScriptEncoder.Default.Encode(tabContent); return(tabContent); }
public ActionResult PublicInfo(string widgetZone, object additionalData = null) { var id = Convert.ToInt32(additionalData); if (id <= 0) { return(Content("")); } var product = _productService.GetProductById(id); if (product == null) { return(Content("")); } if (widgetZone == "product_by_artist") { return(ArtistProducts(product.Id)); } if (widgetZone == "productdetails_bottom" || widgetZone == "productbox_addinfo_after") { var specAttr = _specificationAttributeService.GetProductSpecificationAttributes(product.Id); var imageSpecAttrOption = specAttr.Select(x => x.SpecificationAttributeOption); if (imageSpecAttrOption.Any()) { var defaultColorOption = imageSpecAttrOption.Where(x => x.SpecificationAttribute.Name == "DefaultEnvelopeColor"); var defaultEnvelopType = imageSpecAttrOption.Where(x => x.SpecificationAttribute.Name == "Orientation"); if (defaultEnvelopType.Any()) { string className = defaultEnvelopType.FirstOrDefault().Name; ViewBag.ClassName = className; if (defaultColorOption.Any()) { var optionValue = defaultColorOption.FirstOrDefault().ColorSquaresRgb; ViewBag.DefaultColor = optionValue; } else { ViewBag.DefaultColor = ""; } ViewBag.ProductId = product.Id; return(View("~/Plugins/Products.SpecificationAttributes/Views/SpecificationAttributes/ImageBackground.cshtml")); } } return(Content("")); } if (widgetZone == "product_category_titles") { IEnumerable <ProductCategoryTitleModel> productCategoriesModel = new List <ProductCategoryTitleModel>(); var categories = product.ProductCategories.Select(x => x.Category); productCategoriesModel = categories.Select(x => { return(new ProductCategoryTitleModel { CategoryName = x.Name, SeName = x.GetSeName() }); }); return(View("~/Plugins/Products.SpecificationAttributes/Views/SpecificationAttributes/PoductCategoriesTitles.cshtml", productCategoriesModel)); } if (product.ProductSpecificationAttributes.Any()) { var prodSpecAttriOptions = product.ProductSpecificationAttributes.Select(x => x.SpecificationAttributeOption); if (prodSpecAttriOptions.Any()) { var specAttr = prodSpecAttriOptions.Where(x => x.SpecificationAttribute.Name == "Artist").FirstOrDefault(); if (specAttr != null) { ViewBag.ArtistName = specAttr.Name; ViewBag.ArtistId = specAttr.Id; return(View("~/Plugins/Products.SpecificationAttributes/Views/SpecificationAttributes/PublicInfo.cshtml")); } } } return(Content("")); }
public override decimal GetUnitPrice(Product product, Customer customer, ShoppingCartType shoppingCartType, int quantity, string attributesXml, decimal customerEnteredPrice, DateTime?rentalStartDate, DateTime?rentalEndDate, bool includeDiscounts, out decimal discountAmount, out List <DiscountForCaching> appliedDiscounts) { var miscPlugins = _pluginFinder.GetPlugins <MyPriceCalculationServicePlugin>(storeId: _storeContext.CurrentStore.Id).ToList(); if (miscPlugins.Count > 0) { #region Amalgamation //AMALGAMTION is only for products that use cartons at this point DBManager manager = new DBManager(); ICategoryService iCategoryService = EngineContext.Current.Resolve <ICategoryService>(); ISpecificationAttributeService specService = EngineContext.Current.Resolve <ISpecificationAttributeService>(); //check if amalgamation is on //usp check amalgamation IList <ProductCategory> productCategories = iCategoryService.GetProductCategoriesByProductId(product.Id); //string categoryIds = ""; //for (int i = 0; i < productCategories.Count; i++) //{ // if(i < productCategories.Count && i != 0) // { // categoryIds += "," + productCategories[i].CategoryId.ToString(); // }else // { // categoryIds += productCategories[i].CategoryId.ToString(); // } //} List <int> categoryIdsList = new List <int>(); foreach (var category in productCategories) { categoryIdsList.Add(category.CategoryId); } //eventually current packtype will need to be an attribute passed in string curProductPackType = ""; var curItemSpecAttrs = specService.GetProductSpecificationAttributes(product.Id); foreach (var spec in curItemSpecAttrs) { if (spec.SpecificationAttributeOption.SpecificationAttribute.Name == "Pack Type") { curProductPackType = spec.SpecificationAttributeOption.Name; } } string amalgamationDataQuery = "EXEC usp_SelectGBSAmalgamationMaster @categoryId"; Dictionary <string, object> amalgamationDic = new Dictionary <string, object>(); amalgamationDic.Add("@CategoryId", ""); foreach (var cat in categoryIdsList) { amalgamationDic["@CategoryId"] = cat; DataView amalgamationDataView = manager.GetParameterizedDataView(amalgamationDataQuery, amalgamationDic); if (amalgamationDataView != null && amalgamationDataView.Count > 0 && curProductPackType == "Carton") { ICollection <ShoppingCartItem> cartItemList = customer.ShoppingCartItems; if (cartItemList != null) { List <int> amalgamationMasterCategoryList = new List <int>(); //used if multiple master category id are returned int masterCategoryId; //used to get featured product id int amalgamationGroupId; //group that holds all the associated category ids int bestPriceProductId; int qty = 0; for (int i = 0; i < amalgamationDataView.Count; i++) { //add all return master Ids amalgamationMasterCategoryList.Add(Int32.Parse(amalgamationDataView[i]["masterCategoryId"].ToString())); } int[] masterIdProductIdGroupId = GetRealMasterId(amalgamationMasterCategoryList); masterCategoryId = masterIdProductIdGroupId[0]; bestPriceProductId = masterIdProductIdGroupId[1]; amalgamationGroupId = masterIdProductIdGroupId[2]; List <int> categoryGroupMembersIds = GetCategoryGroupIds(amalgamationGroupId); Dictionary <int, int> qtyEachDic = new Dictionary <int, int>(); //remove items that don't use the carton packtype List <ShoppingCartItem> AmalgamationList = new List <ShoppingCartItem>(); foreach (var item in cartItemList) { var specAttrs = specService.GetProductSpecificationAttributes(item.ProductId); foreach (var spec in specAttrs) { string type = ""; if (spec.SpecificationAttributeOption.SpecificationAttribute.Name == "Pack Type") { type = spec.SpecificationAttributeOption.Name; if (type == "Carton") { //cartItemList.Remove(item); AmalgamationList.Add(item); } } } } for (int i = 0; i < categoryGroupMembersIds.Count; i++) { foreach (ShoppingCartItem item in AmalgamationList) { IList <ProductCategory> cartProductCategories = iCategoryService.GetProductCategoriesByProductId(item.ProductId); foreach (ProductCategory cartCategory in cartProductCategories) { if (cartCategory.CategoryId == categoryGroupMembersIds[i]) { if (!qtyEachDic.ContainsKey(item.Id)) { qtyEachDic.Add(item.Id, item.Quantity); } } } } } foreach (KeyValuePair <int, int> pair in qtyEachDic) { qty += pair.Value; } //qty = 20; product = _productService.GetProductById(bestPriceProductId); quantity = qty; } break; } } //get quantity by finding the number of items that belong to the same alamgamation category //change quantity on get unit price to get proper per unit price. //if (product.Id == 4430) //{ // quantity = 31; //} #endregion Amalgamation decimal finalPrice = base.GetUnitPrice(product, customer, shoppingCartType, quantity, attributesXml, customerEnteredPrice, rentalStartDate, rentalEndDate, includeDiscounts, out discountAmount, out appliedDiscounts); //eventually make this a configurable rules plugin bool hasReturnAddressAttr = false; var attributeValues = _productAttributeParser.ParseProductAttributeValues(attributesXml); decimal returnAddressPriceAdjustment = 0; //int returnAddressMinimumSurchargeID = 0; //bool returnAddressMinimumSurchargeApplied = true; if (attributeValues != null) { foreach (var attributeValue in attributeValues) { if (attributeValue.ProductAttributeMapping.ProductAttribute.Name == "Add Return Address" && attributeValue.Name == "Yes") { hasReturnAddressAttr = true; returnAddressPriceAdjustment = attributeValue.PriceAdjustment; } //if (attributeValue.ProductAttributeMapping.ProductAttribute.Name == "returnAddressMinimumSurcharge" && attributeValue.Name == "Yes") //{ // returnAddressMinimumSurchargeID = attributeValue.Id; // returnAddressMinimumSurchargeApplied = true; //}else //{ // returnAddressMinimumSurchargeApplied = false; //} } } if (hasReturnAddressAttr) { int q = quantity; //quanitity is being set to 1 for product details and Customers Canvas Editor in NOP Core, so have to get it from th Form if (_contextAccessor.HttpContext.Request.Form != null) { foreach (string key in _contextAccessor.HttpContext.Request.Form.Keys) { if (key.Contains("EnteredQuantity")) { q = Int32.Parse(_contextAccessor.HttpContext.Request.Form[key]); } } } if (q < 100) //quantity is being passed from CC correctly? { finalPrice -= returnAddressPriceAdjustment; //eventually make this configurable decimal adj = (5 / (decimal)q); finalPrice += adj; } else { ////remove returnAddressMinimumSurcharge if still on //if (returnAddressMinimumSurchargeApplied) //{ // // _productAttributeParser.ParseProductAttributeMappings(attributesXml); //} } } return(finalPrice); } //if we get here it is because the plugin isn't installed and the base class is called return(base.GetUnitPrice(product, customer, shoppingCartType, quantity, attributesXml, customerEnteredPrice, rentalStartDate, rentalEndDate, includeDiscounts, out discountAmount, out appliedDiscounts)); }
public MarketCenter(int marketCenterCategoryId, bool lightVer = true, bool getChildren = false, string customType = "") { if (marketCenterCategoryId != 0) { this.id = marketCenterCategoryId; Category category = categoryService.GetCategoryById(marketCenterCategoryId); CatalogPagingFilteringModel catalogPagingFilteringModel = new CatalogPagingFilteringModel(); catalogPagingFilteringModel.PageSize = 1; CategoryModel categoryModel = catalogModelFactory.PrepareCategoryModel(category, catalogPagingFilteringModel); this.Name = categoryModel.Name; this.parentCategoryId = _parentCategoryId; this.mainPicturePath = pictureService.GetPictureUrl(category.PictureId); //get spec attribute id and spec attribute option value id if (!string.IsNullOrEmpty(customType)) { specAttrList = specService.GetProductSpecificationAttributes(productId: 0); foreach (var attr in specAttrList) { string typeOptionValue = ""; if (attr.SpecificationAttributeOption.SpecificationAttribute.Name == "Market Center Gateway Type") { specAttributeId = attr.SpecificationAttributeOption.SpecificationAttribute.Id; typeOptionValue = attr.SpecificationAttributeOption.Name; if (typeOptionValue == customType) { specAttributeValueOption = attr.SpecificationAttributeOption.Id; break; } } } //nop check for children categories, query with children category ids to see if any are in the prod attr mapping table //check if market center is at top level for office via query IList <Category> categoriesList = categoryService.GetAllCategoriesByParentCategoryId(marketCenterCategoryId); for (int x = 0; x <= categoriesList.Count; x++) { DataView marketCenterSeView = cacheManager.Get("marketCenterSeLink" + marketCenterCategoryId, 60, () => { Dictionary <string, Object> marketCenterSeDic = new Dictionary <string, Object>(); //int catListId = categoriesList[x].Id; marketCenterSeDic.Add("@CategoryId", categoriesList[x].Id); marketCenterSeDic.Add("@SpecificationAttributeOptionId", specAttributeValueOption); string marketCenterSeDataQuery = "EXEC usp_SelectGBSMarketCenterCustomTypeCategoryId @CategoryId, @SpecificationAttributeOptionId"; DataView innerMarketCenterSeDataView = manager.GetParameterizedDataView(marketCenterSeDataQuery, marketCenterSeDic); return(innerMarketCenterSeDataView); }); if (marketCenterSeView.Count > 0) { seCategoryId = Int32.Parse(marketCenterSeView[x]["tblNopCategoryId"].ToString()); break; } } if (seCategoryId == 0) { //check child count to see if is top office int childMarketCenterCount = GetChildCategories(marketCenterCategoryId, customType, true); if (childMarketCenterCount > 0) { this.SeName = ""; //parent market center child offices will hold links to pages } else { //generate some sort of link that knows what kind of product is missing and where to go this.SeName = "/request-marketcenter-product?type=" + customType + "&company=" + marketCenterCategoryId;//page for market center products that don't exist } } else { Category seCustomLinkCategory = categoryService.GetCategoryById(seCategoryId); CategoryModel seCustomLinkCategoryModel = catalogModelFactory.PrepareCategoryModel(seCustomLinkCategory, catalogPagingFilteringModel); this.SeName = seCustomLinkCategoryModel.SeName; } } else { this.SeName = categoryModel.SeName; } if (lightVer == false) { this.PagingFilteringContext = catalogPagingFilteringModel; this.Description = categoryModel.Description; this.MetaKeywords = categoryModel.MetaKeywords; this.MetaDescription = categoryModel.MetaDescription; this.MetaTitle = categoryModel.MetaTitle; this.PictureModel = categoryModel.PictureModel; this.PagingFilteringContext = categoryModel.PagingFilteringContext; this.DisplayCategoryBreadcrumb = categoryModel.DisplayCategoryBreadcrumb; this.CategoryBreadcrumb = categoryModel.CategoryBreadcrumb; this.SubCategories = categoryModel.SubCategories; this.FeaturedProducts = categoryModel.FeaturedProducts; this.Products = categoryModel.Products; } DataView marketCenterDataView = cacheManager.Get("marketCenter" + marketCenterCategoryId, 60, () => { Dictionary <string, Object> marketCenterDic = new Dictionary <string, Object>(); marketCenterDic.Add("@CategoryId", marketCenterCategoryId); string marketCenterDataQuery = "EXEC usp_SelectGBSCustomCategoryData @categoryId"; DataView innerMarketCenterDataView = manager.GetParameterizedDataView(marketCenterDataQuery, marketCenterDic); return(innerMarketCenterDataView); }); if (marketCenterDataView.Count > 0) { if (lightVer == false) { this.parentCategoryId = category.ParentCategoryId; this.h1 = !string.IsNullOrEmpty(marketCenterDataView[0]["H1"].ToString()) ? marketCenterDataView[0]["H1"].ToString() : this.Name; this.h2 = !string.IsNullOrEmpty(marketCenterDataView[0]["H2"].ToString()) ? marketCenterDataView[0]["H2"].ToString() : _h2; this.topText = !string.IsNullOrEmpty(marketCenterDataView[0]["UpperText"].ToString()) ? marketCenterDataView[0]["UpperText"].ToString() : _topText; this.bottomText = !string.IsNullOrEmpty(marketCenterDataView[0]["LowerText"].ToString()) ? marketCenterDataView[0]["LowerText"].ToString() : _bottomText; this.backgroundImage = !string.IsNullOrEmpty(marketCenterDataView[0]["BackgroundPicturePath"].ToString()) ? marketCenterDataView[0]["BackgroundPicturePath"].ToString() : _backgroundImage; this.foregroundImage = !string.IsNullOrEmpty(marketCenterDataView[0]["ForegroundPicturePath"].ToString()) ? marketCenterDataView[0]["ForegroundPicturePath"].ToString() : _foregroundImage; this.backgroundColor = !string.IsNullOrEmpty(marketCenterDataView[0]["BackgroundColor"].ToString()) ? marketCenterDataView[0]["BackgroundColor"].ToString() : _backgroundColor; } //marketcenter custom data this.isTopCompany = !string.IsNullOrEmpty(marketCenterDataView[0]["IsFeatured"].ToString()) ? Convert.ToBoolean(marketCenterDataView[0]["IsFeatured"]) : isTopCompany = _isTopCompany; if (this.isTopCompany) { if (!string.IsNullOrEmpty(marketCenterDataView[0]["LogoPicturePath"].ToString())) { this.mainPicturePath = marketCenterDataView[0]["LogoPicturePath"].ToString(); } else { this.mainPicturePath = !string.IsNullOrEmpty(marketCenterDataView[0]["MainPicturePath"].ToString()) ? marketCenterDataView[0]["MainPicturePath"].ToString() : _mainPicturePath; } } } #region child companies //if (getChildren) //{ // GetChildCategories(marketCenterCategoryId, customType); //} #endregion } }
public List <TreatmentData> getTreatmentData(OrderDetailsModel orderDetailsModel) { List <TreatmentData> treatmentDataList = new List <TreatmentData>(); foreach (var orderItemModel in orderDetailsModel.Items) { TreatmentData treatmentDataItem = new TreatmentData(); treatmentDataItem.id = orderItemModel.Id; var specAttr = _specificationAttributeService.GetProductSpecificationAttributes(orderItemModel.ProductId); var imageSpecAttrOption = specAttr.Select(x => x.SpecificationAttributeOption); if (imageSpecAttrOption.Any()) { var thumbnailBackground = imageSpecAttrOption.Where(x => x.SpecificationAttribute.Name == "Treatment"); if (thumbnailBackground.Any()) { foreach (var thbackground in thumbnailBackground) { var gbsBackGroundName = thbackground.Name; treatmentDataItem.DefaultColor = ""; treatmentDataItem.ClassName = ""; if (gbsBackGroundName.Any()) { switch (gbsBackGroundName) { case "TreatmentImage": var backGroundShapeName = imageSpecAttrOption.Where(x => x.SpecificationAttribute.Name == gbsBackGroundName); if (backGroundShapeName.Any()) { treatmentDataItem.ClassName = backGroundShapeName.FirstOrDefault().Name; } break; case "TreatmentFill": var backGroundFillOption = imageSpecAttrOption.Where(x => x.SpecificationAttribute.Name == gbsBackGroundName); if (backGroundFillOption.Any()) { var fillOptionValue = backGroundFillOption.FirstOrDefault().Name; switch (fillOptionValue) { case "TreatmentFillPattern": var img = imageSpecAttrOption.Where(x => x.SpecificationAttribute.Name == backGroundFillOption.FirstOrDefault().Name); if (img.Any()) { treatmentDataItem.DefaultColor = "background-image:url('" + img.FirstOrDefault().ColorSquaresRgb + "')"; } break; case "TreatmentFillColor": var color = imageSpecAttrOption.Where(x => x.SpecificationAttribute.Name == backGroundFillOption.FirstOrDefault().Name); if (color.Any()) { treatmentDataItem.DefaultColor = "background-color:" + color.FirstOrDefault().ColorSquaresRgb; } break; } } break; } } } } else { var defaultColorOption = imageSpecAttrOption.Where(x => x.SpecificationAttribute.Name == "DefaultEnvelopeColor"); var defaultEnvelopType = imageSpecAttrOption.Where(x => x.SpecificationAttribute.Name == "Orientation"); if (defaultEnvelopType.Any()) { string className = defaultEnvelopType.FirstOrDefault().Name; treatmentDataItem.ClassName = className; if (defaultColorOption.Any()) { var optionValue = defaultColorOption.FirstOrDefault().ColorSquaresRgb; treatmentDataItem.DefaultColor = optionValue; if (optionValue.Contains("#") && optionValue.Length == 7) { treatmentDataItem.DefaultColor = "background-color:" + optionValue; } else { treatmentDataItem.DefaultColor = "background-image:url('" + optionValue + "')"; } } else { treatmentDataItem.DefaultColor = ""; } } } } treatmentDataList.Add(treatmentDataItem); } return(treatmentDataList); }