/// <summary> /// Prepare manufacturer model /// </summary> /// <param name="model">Manufacturer model</param> /// <param name="manufacturer">Manufacturer</param> /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param> /// <returns>Manufacturer model</returns> public virtual ManufacturerModel PrepareManufacturerModel(ManufacturerModel model, Manufacturer manufacturer, bool excludeProperties = false) { Action <ManufacturerLocalizedModel, int> localizedModelConfiguration = null; if (manufacturer != null) { //fill in model values from the entity model = model ?? manufacturer.ToModel(); //prepare nested search model PrepareManufacturerProductSearchModel(model.ManufacturerProductSearchModel, manufacturer); //define localized model configuration action localizedModelConfiguration = (locale, languageId) => { locale.Name = manufacturer.GetLocalized(entity => entity.Name, languageId, false, false); locale.Description = manufacturer.GetLocalized(entity => entity.Description, languageId, false, false); locale.MetaKeywords = manufacturer.GetLocalized(entity => entity.MetaKeywords, languageId, false, false); locale.MetaDescription = manufacturer.GetLocalized(entity => entity.MetaDescription, languageId, false, false); locale.MetaTitle = manufacturer.GetLocalized(entity => entity.MetaTitle, languageId, false, false); locale.SeName = manufacturer.GetSeName(languageId, false, false); }; } //set default values for the new model if (manufacturer == null) { model.PageSize = _catalogSettings.DefaultManufacturerPageSize; model.PageSizeOptions = _catalogSettings.DefaultManufacturerPageSizeOptions; model.Published = true; model.AllowCustomersToSelectPageSize = true; } //prepare localized models if (!excludeProperties) { model.Locales = _localizedModelFactory.PrepareLocalizedModels(localizedModelConfiguration); } //prepare available manufacturer templates _baseAdminModelFactory.PrepareManufacturerTemplates(model.AvailableManufacturerTemplates, false); //prepare model discounts var availableDiscounts = _discountService.GetAllDiscounts(DiscountType.AssignedToManufacturers, showHidden: true); _discountSupportedModelFactory.PrepareModelDiscounts(model, manufacturer, availableDiscounts, excludeProperties); //prepare model customer roles _aclSupportedModelFactory.PrepareModelCustomerRoles(model, manufacturer, excludeProperties); //prepare model stores _storeMappingSupportedModelFactory.PrepareModelStores(model, manufacturer, excludeProperties); return(model); }
//manufacturer public static ManufacturerModel ToModel(this Manufacturer entity) { if (entity == null) { return(null); } var model = new ManufacturerModel { Id = entity.Id, Name = entity.GetLocalized(x => x.Name), Description = entity.GetLocalized(x => x.Description), MetaKeywords = entity.GetLocalized(x => x.MetaKeywords), MetaDescription = entity.GetLocalized(x => x.MetaDescription), MetaTitle = entity.GetLocalized(x => x.MetaTitle), SeName = entity.GetSeName(), }; return(model); }
//manufacturer public static ManufacturerModel ToModel(this Manufacturer entity, Language language) { if (entity == null) { return(null); } var model = new ManufacturerModel { Id = entity.Id, Name = entity.GetLocalized(x => x.Name, language.Id), Description = entity.GetLocalized(x => x.Description, language.Id), MetaKeywords = entity.GetLocalized(x => x.MetaKeywords, language.Id), MetaDescription = entity.GetLocalized(x => x.MetaDescription, language.Id), MetaTitle = entity.GetLocalized(x => x.MetaTitle, language.Id), SeName = entity.GetSeName(language.Id), Icon = entity.Icon }; return(model); }