/// <summary>
        /// Prepare paged manufacturer template list model
        /// </summary>
        /// <param name="searchModel">Manufacturer template search model</param>
        /// <returns>Manufacturer template list model</returns>
        public virtual ManufacturerTemplateListModel PrepareManufacturerTemplateListModel(ManufacturerTemplateSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get manufacturer templates
            var manufacturerTemplates = _manufacturerTemplateService.GetAllManufacturerTemplates().ToPagedList(searchModel);

            //prepare grid model
            var model = new ManufacturerTemplateListModel().PrepareToGrid(searchModel, manufacturerTemplates,
                                                                          () => manufacturerTemplates.Select(template => template.ToModel <ManufacturerTemplateModel>()));

            return(model);
        }
Esempio n. 2
0
        /// <summary>
        /// Prepare paged manufacturer template list model
        /// </summary>
        /// <param name="searchModel">Manufacturer template search model</param>
        /// <returns>Manufacturer template list model</returns>
        public virtual ManufacturerTemplateListModel PrepareManufacturerTemplateListModel(ManufacturerTemplateSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get manufacturer templates
            var manufacturerTemplates = _manufacturerTemplateService.GetAllManufacturerTemplates();

            //prepare grid model
            var model = new ManufacturerTemplateListModel
            {
                //fill in model values from the entity
                Data  = manufacturerTemplates.PaginationByRequestModel(searchModel).Select(template => template.ToModel()),
                Total = manufacturerTemplates.Count
            };

            return(model);
        }