Esempio n. 1
0
        /// <summary>
        /// Prepare paged pickup point provider list model
        /// </summary>
        /// <param name="searchModel">Pickup point provider search model</param>
        /// <returns>Pickup point provider list model</returns>
        public virtual PickupPointProviderListModel PreparePickupPointProviderListModel(PickupPointProviderSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get pickup point providers
            var pickupPointProviders = _shippingService.LoadAllPickupPointProviders();

            //prepare grid model
            var model = new PickupPointProviderListModel
            {
                Data = pickupPointProviders.PaginationByRequestModel(searchModel).Select(provider =>
                {
                    //fill in model values from the entity
                    var pickupPointProviderModel = provider.ToModel();

                    //fill in additional values (not existing in the entity)
                    pickupPointProviderModel.IsActive         = provider.IsPickupPointProviderActive(_shippingSettings);
                    pickupPointProviderModel.ConfigurationUrl = provider.GetConfigurationPageUrl();
                    pickupPointProviderModel.LogoUrl          = provider.PluginDescriptor.GetLogoUrl(_webHelper);

                    return(pickupPointProviderModel);
                }),
                Total = pickupPointProviders.Count
            };

            return(model);
        }
Esempio n. 2
0
        /// <summary>
        /// Prepare paged pickup point provider list model
        /// </summary>
        /// <param name="searchModel">Pickup point provider search model</param>
        /// <returns>Pickup point provider list model</returns>
        public virtual PickupPointProviderListModel PreparePickupPointProviderListModel(PickupPointProviderSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get pickup point providers
            var pickupPointProviders = _pickupPluginManager.LoadAllPlugins().ToPagedList(searchModel);

            //prepare grid model
            var model = new PickupPointProviderListModel().PrepareToGrid(searchModel, pickupPointProviders, () =>
            {
                return(pickupPointProviders.Select(provider =>
                {
                    //fill in model values from the entity
                    var pickupPointProviderModel = provider.ToPluginModel <PickupPointProviderModel>();

                    //fill in additional values (not existing in the entity)
                    pickupPointProviderModel.IsActive = _pickupPluginManager.IsPluginActive(provider);
                    pickupPointProviderModel.ConfigurationUrl = provider.GetConfigurationPageUrl();
                    pickupPointProviderModel.LogoUrl = _pickupPluginManager.GetPluginLogoUrl(provider);

                    return pickupPointProviderModel;
                }));
            });

            return(model);
        }