Browse Source

webapi server

pull/3/head
Your Name 3 years ago
parent
commit
f690ecc527
  1. 6
      20230415.3/w230415/w230415.sln
  2. 42
      20230415.3/w230415_consoleapi/Program.cs
  3. 18
      20230415.3/w230415_consoleapi/w230415_consoleapi.csproj

6
20230415.3/w230415/w230415.sln

@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "w230415_console", "..\w2304
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "w230415_webapi", "..\w230415_webapi\w230415_webapi.csproj", "{465CAE58-3BB5-4933-8AB8-FE30DDCFB9C4}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "w230415_webapi", "..\w230415_webapi\w230415_webapi.csproj", "{465CAE58-3BB5-4933-8AB8-FE30DDCFB9C4}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "w230415_consoleapi", "..\w230415_consoleapi\w230415_consoleapi.csproj", "{96A7178E-082A-4E3B-A377-948D0B1E66DA}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -27,6 +29,10 @@ Global
{465CAE58-3BB5-4933-8AB8-FE30DDCFB9C4}.Debug|Any CPU.Build.0 = Debug|Any CPU {465CAE58-3BB5-4933-8AB8-FE30DDCFB9C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{465CAE58-3BB5-4933-8AB8-FE30DDCFB9C4}.Release|Any CPU.ActiveCfg = Release|Any CPU {465CAE58-3BB5-4933-8AB8-FE30DDCFB9C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{465CAE58-3BB5-4933-8AB8-FE30DDCFB9C4}.Release|Any CPU.Build.0 = Release|Any CPU {465CAE58-3BB5-4933-8AB8-FE30DDCFB9C4}.Release|Any CPU.Build.0 = Release|Any CPU
{96A7178E-082A-4E3B-A377-948D0B1E66DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{96A7178E-082A-4E3B-A377-948D0B1E66DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{96A7178E-082A-4E3B-A377-948D0B1E66DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{96A7178E-082A-4E3B-A377-948D0B1E66DA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

42
20230415.3/w230415_consoleapi/Program.cs

@ -0,0 +1,42 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using w230415_classes;
namespace w230415_consoleapi
{
internal class Program
{
static void Main(string[] args)
{
h_Process();
}
private static void h_Process()
{
HttpClient client = new HttpClient();
var res = client.GetAsync("http://localhost:5095/v1/hall").Result;
if (res.StatusCode == System.Net.HttpStatusCode.OK)
{
string sJson = res.Content.ReadAsStringAsync().Result;
//// 1. self
List<HallPlace>? chList = JsonConvert.DeserializeObject<List<HallPlace>>(sJson);
foreach (HallPlace item in chList)
{
Console.WriteLine($"{item.SeatRow}/{item.SeatPosition}: {item.Uid}");
}
// 2. dynamic
//dynamic json = JsonConvert.DeserializeObject(sJson);
//foreach (dynamic item in json)
//{
// Console.WriteLine($"{item.seatRow}/{item.seatPosition}: {item.uid}");
//}
// 3. JToken
//JToken json = JsonConvert.DeserializeObject<JToken>(sJson);
//foreach (JToken item in json)
//{
// Console.WriteLine($"{item["seatRow"]}/{item["seatPosition"]}: {item["uid"]}");
//}
}
}
}
}

18
20230415.3/w230415_consoleapi/w230415_consoleapi.csproj

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\w230415\w230415_classes.csproj" />
</ItemGroup>
</Project>
Loading…
Cancel
Save