public override DataSourceResult GetMods(DataSourceRequest request)
        {
            var modIoConfiguration = ModIoBrowser.GetModIoConfigurationForCurrentGame();
            var titleQuery         = "";
            var categoryQuery      = "";
            var sortQuery          = "title";
            var filters            = request.GetAllFilterDescriptors();
            var titleFilter        = filters.FirstOrDefault(x => x.Member == "Name");

            if (titleFilter != null)
            {
                titleQuery = titleFilter.Value.ToString();
            }

            var categoryFilter = filters.FirstOrDefault(x => x.Member == "Category");

            if (categoryFilter != null)
            {
                categoryQuery = categoryFilter.Value.ToString();
            }

            var mods = MMods.GetModsForGame(modIoConfiguration.SelectedGameId, titleQuery, request.Page, request.PageSize);

            request.Filters = new List <IFilterDescriptor>();
            var dataSourceResult = mods.Data.ToDataSourceResult(request);

            dataSourceResult.Total = mods.ResultTotal;
            dataSourceResult.Data  = mods.Data;
            return(dataSourceResult);
        }
        public override DataSourceResult GetMods([DataSourceRequest] DataSourceRequest request)
        {
            var installed  = this.GetInstalledPlugins(TCAdmin.GameHosting.SDK.Objects.Service.GetSelectedService());
            var filters    = request.GetAllFilterDescriptors();
            var query      = string.Empty;
            var termFilter = filters.FirstOrDefault(x => x.Member == "Term");
            var sortBy     = (filters.FirstOrDefault(x => x.Member == "SortBy") ?? new Kendo.Mvc.FilterDescriptor("SortBy", Kendo.Mvc.FilterOperator.Contains, installed.Count > 0 ? "installed" : "modpack/featured")).Value.ToString();
            List <MinecraftModpacksBrowser> mods = null;

            if (sortBy == "installed")
            {
                mods = new List <MinecraftModpacksBrowser>();
                foreach (var modpack in installed)
                {
                    var pack = MinecraftModpacksBrowser.GetPack(int.Parse(modpack.Split(':')[0].Replace("MCMP", string.Empty)));
                    if (pack.Status == "success")
                    {
                        mods.Add(pack);
                    }
                    else
                    {
                        pack = MinecraftModpacksBrowser.GetCurseforgePack(int.Parse(modpack.Split(':')[0].Replace("MCMP", string.Empty)));
                        if (pack.Status == "success")
                        {
                            mods.Add(pack);
                        }
                    }
                }
            }
            else
            {
                if (termFilter != null && !string.IsNullOrEmpty(termFilter.Value.ToString()))
                {
                    sortBy = "modpack/search";
                    query  = termFilter.Value.ToString();
                }

                mods = MinecraftModpacksBrowser.Search(sortBy, query, request.Page, request.PageSize);
            }

            request.Filters = new List <IFilterDescriptor>();
            var dataSourceResult = mods.ToDataSourceResult(request);

            dataSourceResult.Total = 5000;
            dataSourceResult.Data  = mods;
            return(dataSourceResult);
        }
示例#3
0
        public override DataSourceResult GetMods(DataSourceRequest request)
        {
            var filters     = request.GetAllFilterDescriptors();
            var query       = "";
            var titleFilter = filters.FirstOrDefault(x => x.Member == "Name");

            if (titleFilter != null)
            {
                query = titleFilter.Value.ToString();
            }

            var mods = CurseBrowser.Search(query, request.Page);

            request.Filters = new List <IFilterDescriptor>();
            var dataSourceResult = mods.ToDataSourceResult(request);

            dataSourceResult.Total = 500;
            dataSourceResult.Data  = mods;
            return(dataSourceResult);
        }
示例#4
0
        public override DataSourceResult GetMods(DataSourceRequest request)
        {
            var titleQuery    = "";
            var categoryQuery = "rust";
            var sortQuery     = "title";
            var filters       = request.GetAllFilterDescriptors();
            var titleFilter   = filters.FirstOrDefault(x => x.Member == "Title");

            if (titleFilter != null)
            {
                titleQuery = titleFilter.Value.ToString();
            }

            var categoryFilter = filters.FirstOrDefault(x => x.Member == "Category");

            if (categoryFilter != null)
            {
                categoryQuery = categoryFilter.Value.ToString();
            }

            var sortFilter = filters.FirstOrDefault(x => x.Member == "SortBy");

            if (sortFilter != null)
            {
                sortQuery = sortFilter.Value.ToString();
            }

            var uModBrowser = UModBrowser.Search(titleQuery, request.Page, sort: sortQuery, category: categoryQuery);

            request.Filters = new List <IFilterDescriptor>();
            var dataSourceResult = uModBrowser.Mods.ToDataSourceResult(request);

            dataSourceResult.Total = uModBrowser.Total;
            dataSourceResult.Data  = uModBrowser.Mods;
            return(dataSourceResult);
        }