/// <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);
        }
Esempio n. 2
0
        //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);
        }
Esempio n. 3
0
        public static Manufacturer ToModel(this Manufacturer entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var model = new Manufacturer
            {
                Id           = entity.Id,
                OtherLink    = entity.OtherLink,
                Status       = entity.Status,
                OrderDisplay = entity.OrderDisplay,
                ImageUrl     = entity.ImageUrl,

                Title       = entity.GetLocalized(x => x.Title, entity.Id),
                Description = entity.GetLocalized(x => x.Description, entity.Id)
            };

            return(model);
        }
Esempio n. 4
0
        //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);
        }
Esempio n. 5
0
        public async Task <BrandModel> PrepareBrandModelAsync(Manufacturer manufacturer)
        {
            if (manufacturer == null)
            {
                return(null);
            }

            var model = new BrandModel
            {
                Id                = manufacturer.Id,
                Name              = manufacturer.GetLocalized(x => x.Name),
                Description       = manufacturer.GetLocalized(x => x.Description, detectEmptyHtml: true),
                BottomDescription = manufacturer.GetLocalized(x => x.BottomDescription, detectEmptyHtml: true),
                MetaKeywords      = manufacturer.GetLocalized(x => x.MetaKeywords),
                MetaDescription   = manufacturer.GetLocalized(x => x.MetaDescription),
                MetaTitle         = manufacturer.GetLocalized(x => x.MetaTitle),
                SeName            = await manufacturer.GetActiveSlugAsync()
            };

            model.MetaProperties = PrepareMetaPropertiesBrand(model);

            return(model);
        }