public async Task <OperationDataResult <PluginsStoreModel> > GetMarketplacePlugins(MarketplacePluginsRequestModel model) { return(await _pluginsManagementService.GetMarketplacePlugins(model)); }
public async Task <OperationDataResult <PluginsStoreModel> > GetMarketplacePlugins(MarketplacePluginsRequestModel model) { try { var url = _options.Value.PluginListLink; var httpClient = _httpClientFactory.CreateClient(); var stream = httpClient.GetStreamAsync(url).Result; string json; using (var reader = new StreamReader(stream)) { json = await reader.ReadToEndAsync(); } if (string.IsNullOrEmpty(json)) { throw new Exception("Error while obtaining json file"); } var list = JsonConvert.DeserializeObject <List <PluginStoreModel> >(json); var result = new PluginsStoreModel() { Total = list.Count, PluginsList = list, }; return(new OperationDataResult <PluginsStoreModel>(true, result)); } catch (Exception e) { _logger.LogError(e.Message); return(new OperationDataResult <PluginsStoreModel>(false, _localizationService.GetString("ErrorWhileObtainingPluginList"))); } }