Example #1
0
        public ActionResult OfficialFeedSelect(DataSourceRequest command, OfficialFeedListModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManagePlugins))
            {
                return(AccessDeniedView());
            }

            var plugins = _officialFeedManager.GetAllPlugins(model.SearchCategoryId, model.SearchVersionId,
                                                             model.SearchPriceId, model.SearchName, command.Page - 1, command.PageSize);

            var gridModel = new DataSourceResult();

            gridModel.Data = plugins.Select(x => new OfficialFeedListModel.ItemOverview
            {
                Url               = x.Url,
                Name              = x.Name,
                CategoryName      = x.Category,
                SupportedVersions = x.SupportedVersions,
                PictureUrl        = x.PictureUrl,
                Price             = x.Price
            });
            gridModel.Total = plugins.TotalCount;

            return(Json(gridModel));
        }
Example #2
0
        /// <summary>
        /// Prepare paged list model of plugins of the official feed
        /// </summary>
        /// <param name="searchModel">Search model of plugins of the official feed</param>
        /// <returns>List model of plugins of the official feed</returns>
        public virtual OfficialFeedPluginListModel PrepareOfficialFeedPluginListModel(OfficialFeedPluginSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get plugins
            var plugins = _officialFeedManager.GetAllPlugins(categoryId: searchModel.SearchCategoryId,
                                                             versionId: searchModel.SearchVersionId,
                                                             price: searchModel.SearchPriceId,
                                                             searchTerm: searchModel.SearchName,
                                                             pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize);

            //prepare list model
            var model = new OfficialFeedPluginListModel
            {
                //fill in model values from the entity
                Data = plugins.Select(plugin => new OfficialFeedPluginModel
                {
                    Url               = plugin.Url,
                    Name              = plugin.Name,
                    CategoryName      = plugin.Category,
                    SupportedVersions = plugin.SupportedVersions,
                    PictureUrl        = plugin.PictureUrl,
                    Price             = plugin.Price
                }),
                Total = plugins.TotalCount
            };

            return(model);
        }
Example #3
0
        public virtual IActionResult OfficialFeedSelect(DataSourceRequest command, OfficialFeedListModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManagePlugins))
            {
                return(AccessDeniedKendoGridJson());
            }

            var plugins = _officialFeedManager.GetAllPlugins(categoryId: model.SearchCategoryId,
                                                             versionId: model.SearchVersionId,
                                                             price: model.SearchPriceId,
                                                             searchTerm: model.SearchName,
                                                             pageIndex: command.Page - 1,
                                                             pageSize: command.PageSize);

            var gridModel = new DataSourceResult
            {
                Data = plugins.Select(x => new OfficialFeedListModel.ItemOverview
                {
                    Url               = x.Url,
                    Name              = x.Name,
                    CategoryName      = x.Category,
                    SupportedVersions = x.SupportedVersions,
                    PictureUrl        = x.PictureUrl,
                    Price             = x.Price
                }),
                Total = plugins.TotalCount
            };

            return(Json(gridModel));
        }
Example #4
0
        /// <summary>
        /// Prepare paged list model of plugins of the official feed
        /// </summary>
        /// <param name="searchModel">Search model of plugins of the official feed</param>
        /// <returns>List model of plugins of the official feed</returns>
        public virtual OfficialFeedPluginListModel PrepareOfficialFeedPluginListModel(OfficialFeedPluginSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get plugins
            IPagedList <OfficialFeedPlugin> plugins = null;

            try
            {
                //ensure that no exception is thrown when www.nopcommerce.com website is not available
                plugins = _officialFeedManager.GetAllPlugins(categoryId: searchModel.SearchCategoryId,
                                                             versionId: searchModel.SearchVersionId,
                                                             price: searchModel.SearchPriceId,
                                                             searchTerm: searchModel.SearchName,
                                                             pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize);
            }
            catch (Exception ex)
            {
                _logger.Error("No access to the list of plugins. Website www.nopcommerce.com is not available.", ex);
            }

            //prepare list model
            var model = new OfficialFeedPluginListModel
            {
                //fill in model values from the entity
                Data = plugins?.Select(plugin => new OfficialFeedPluginModel
                {
                    Url               = plugin.Url,
                    Name              = plugin.Name,
                    CategoryName      = plugin.Category,
                    SupportedVersions = plugin.SupportedVersions,
                    PictureUrl        = plugin.PictureUrl,
                    Price             = plugin.Price
                }) ?? new List <OfficialFeedPluginModel>(),
                Total = plugins?.TotalCount ?? 0
            };

            return(model);
        }