Skip to content

Commit

Permalink
guillegr123#9 - Create library to get matches information from world …
Browse files Browse the repository at this point in the history
…cup teams api
  • Loading branch information
willescobar30 committed Jun 25, 2018
1 parent bca8407 commit f3a4bf0
Show file tree
Hide file tree
Showing 9 changed files with 602 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ConsoleApp1/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
68 changes: 68 additions & 0 deletions ConsoleApp1/ConsoleApp1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F0CB44AD-F34B-45DE-A544-3FEEEBFA3455}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ConsoleApp1</RootNamespace>
<AssemblyName>ConsoleApp1</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Flurl, Version=2.7.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Flurl.2.7.1\lib\net40\Flurl.dll</HintPath>
</Reference>
<Reference Include="Flurl.Http, Version=2.3.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Flurl.Http.2.3.1\lib\net45\Flurl.Http.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\QW.ExternalApi\QW.ExternalApi.csproj">
<Project>{1c9bfcc1-6395-4722-b841-5545f2e94f15}</Project>
<Name>QW.ExternalApi</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
21 changes: 21 additions & 0 deletions ConsoleApp1/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using QW.ExternalApi;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
class Program
{

static void Main(string[] args)
{
Console.WriteLine("Hello World!");

HttpClientMatch.downloadJSONData();
Console.ReadKey();
}
}
}
36 changes: 36 additions & 0 deletions ConsoleApp1/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ConsoleApp1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Hewlett-Packard")]
[assembly: AssemblyProduct("ConsoleApp1")]
[assembly: AssemblyCopyright("Copyright © Hewlett-Packard 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f0cb44ad-f34b-45de-a544-3feeebfa3455")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
6 changes: 6 additions & 0 deletions ConsoleApp1/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Flurl" version="2.7.1" targetFramework="net461" />
<package id="Flurl.Http" version="2.3.1" targetFramework="net461" />
<package id="Newtonsoft.Json" version="11.0.1" targetFramework="net461" />
</packages>
70 changes: 70 additions & 0 deletions QW.ExternalApi/HttpClientMatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Flurl.Http;
using QW.ExternalApi.Models;

namespace QW.ExternalApi
{
public class HttpClientMatch
{

private static SynchronizationContext synchronizationContext;
public static RootObject worldCupDara;

public static async void downloadJSONData()
{

try
{
//PERFORM IN BACKGROUND
// await Task.Run(async () =>
// {
worldCupDara = await "https://raw.githubusercontent.com/lsv/fifa-worldcup-2018/master/data.json".GetJsonAsync<RootObject>();

//Console.WriteLine(users.ToString());
/* foreach (Team user in worldCupDara.teams)
{
synchronizationContext.Post(new SendOrPostCallback(value =>
{
//UPDATE ComboBox
}), user.Name);
}*/
// });
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}

public Team getTeamByfifaCode(String fifaCode)
{
foreach (Team user in worldCupDara.teams)
{
synchronizationContext.Post(new SendOrPostCallback(value =>
{
//UPDATE ComboBox
//myComboBox.Items.Add(value as string);

}), user.fifaCode);
}



return null;
}


}

class User
{
public string Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
}
}
Loading

0 comments on commit f3a4bf0

Please sign in to comment.