/// <summary> /// Prepare category model /// </summary> /// <param name="model">Category model</param> /// <param name="category">Category</param> /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param> /// <returns>Category model</returns> public virtual CategoryModel PrepareCategoryModel(CategoryModel model, Category category, bool excludeProperties = false) { Action <CategoryLocalizedModel, int> localizedModelConfiguration = null; if (category != null) { //fill in model values from the entity model = model ?? category.ToModel <CategoryModel>(); //prepare nested search model PrepareCategoryProductSearchModel(model.CategoryProductSearchModel, category); //define localized model configuration action localizedModelConfiguration = (locale, languageId) => { locale.Name = _localizationService.GetLocalized(category, entity => entity.Name, languageId, false, false); locale.Description = _localizationService.GetLocalized(category, entity => entity.Description, languageId, false, false); locale.MetaKeywords = _localizationService.GetLocalized(category, entity => entity.MetaKeywords, languageId, false, false); locale.MetaDescription = _localizationService.GetLocalized(category, entity => entity.MetaDescription, languageId, false, false); locale.MetaTitle = _localizationService.GetLocalized(category, entity => entity.MetaTitle, languageId, false, false); locale.SeName = _urlRecordService.GetSeName(category, languageId, false, false); }; } //set default values for the new model if (category == null) { model.PageSize = _catalogSettings.DefaultCategoryPageSize; model.PageSizeOptions = _catalogSettings.DefaultCategoryPageSizeOptions; model.Published = true; model.IncludeInTopMenu = true; model.AllowCustomersToSelectPageSize = true; } //prepare localized models if (!excludeProperties) { model.Locales = _localizedModelFactory.PrepareLocalizedModels(localizedModelConfiguration); } //prepare available category templates _baseAdminModelFactory.PrepareCategoryTemplates(model.AvailableCategoryTemplates, false); //prepare available parent categories _baseAdminModelFactory.PrepareCategories(model.AvailableCategories, defaultItemText: _localizationService.GetResource("Admin.Catalog.Categories.Fields.Parent.None")); //prepare model discounts var availableDiscounts = _discountService.GetAllDiscounts(DiscountType.AssignedToCategories, showHidden: true); _discountSupportedModelFactory.PrepareModelDiscounts(model, category, availableDiscounts, excludeProperties); //prepare model customer roles _aclSupportedModelFactory.PrepareModelCustomerRoles(model, category, excludeProperties); //prepare model stores _storeMappingSupportedModelFactory.PrepareModelStores(model, category, excludeProperties); return(model); }
/// <summary> /// Prepare category model /// </summary> /// <param name="model">Category model</param> /// <param name="category">Category</param> /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param> /// <returns>Category model</returns> public virtual CategoryModel PrepareCategoryModel(CategoryModel model, Category category, bool excludeProperties = false) { if (category != null) { //fill in model values from the entity model = model ?? category.ToModel <CategoryModel>(); } //set default values for the new model if (category == null) { model.Published = true; model.IncludeInTopMenu = true; model.IncludeInFooterMenu = false; model.IncludeInManset = false; } //prepare available category templates _baseAdminModelFactory.PrepareCategoryTemplates(model.AvailableCategoryTemplates, false); //prepare available parent categories _baseAdminModelFactory.PrepareCategories(model.AvailableCategories, defaultItemText: "Kategori Seç"); _baseAdminModelFactory.PrepareSliders(model.AvailableSliders, true, "Slider Seçebiliirsiniz"); _baseAdminModelFactory.PreparePhotoGalleries(model.AvailablePhotoGallery, true, "Galeri Sçebilirsiniz"); _baseAdminModelFactory.PrepareVideoGalleries(model.AvailableVideoGalleries, true, "Video Galeri Seçebilirsiniz"); return(model); }