From 0d58d5079958c95c9e2eba6e4c682b12b63fddc3 Mon Sep 17 00:00:00 2001 From: Naushad Warsi Date: Wed, 13 Nov 2019 13:40:38 +0530 Subject: [PATCH] POC work is done here --- .../Controllers/ValuesController.cs | 4 ++-- .../IRestService.cs | 2 +- samples/ConsoleSampleUsingLocalApi/Program.cs | 17 ++++++++--------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/ApiApplication/RestApiforTest/Controllers/ValuesController.cs b/ApiApplication/RestApiforTest/Controllers/ValuesController.cs index 6f3cb05..4fd6e78 100644 --- a/ApiApplication/RestApiforTest/Controllers/ValuesController.cs +++ b/ApiApplication/RestApiforTest/Controllers/ValuesController.cs @@ -10,9 +10,9 @@ public class ValuesController : ControllerBase { // GET api/values [HttpGet] - public ActionResult> Get() + public ActionResult Get() { - return new string[] { "value1", "value2" }; + return "Get Api with no argument was Called"; } // GET api/values/5 diff --git a/InterLibraries/LibraryWithSDKandRefitService/IRestService.cs b/InterLibraries/LibraryWithSDKandRefitService/IRestService.cs index d42c02d..dc34baa 100644 --- a/InterLibraries/LibraryWithSDKandRefitService/IRestService.cs +++ b/InterLibraries/LibraryWithSDKandRefitService/IRestService.cs @@ -7,7 +7,7 @@ namespace LibraryWithSDKandRefitService public interface IRestService { [Get("/api/values")] - Task> GetWithNoParameter(); + Task GetWithNoParameter(); [Get("/api/values/{id}")] Task GetWithParameter([AliasAs("id")] int id); diff --git a/samples/ConsoleSampleUsingLocalApi/Program.cs b/samples/ConsoleSampleUsingLocalApi/Program.cs index b0d84d4..2d3547f 100644 --- a/samples/ConsoleSampleUsingLocalApi/Program.cs +++ b/samples/ConsoleSampleUsingLocalApi/Program.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Net.Http; using System.Net.Http.Headers; using LibraryWithSDKandRefitService; @@ -13,35 +14,33 @@ static void Main(string[] args) Console.WriteLine("Hello World!"); HttpClient _client = new HttpClient { - BaseAddress = new Uri("https://api.github.com") + BaseAddress = new Uri("http://localhost:61868") }; - IRestService _restApiService = RestService.For(_client); - + Console.WriteLine("Enter from the following numbers to access the APIs,\n1 for get ,\n2 for get with argument, \n3 for post,\n4 for put, \n5 for Delete \n"); while (true) { - Console.WriteLine("Enter from the following numbers to access the APIs,\n1 for get ,\n2 for get with argument, \n3 for post,\n4 for put, \n5 for Delete \n"); int choice = Int32.Parse(Console.ReadLine() ?? "6"); switch (choice) { case 1: - var result1 = _restApiService.GetWithNoParameter(); + var result1 = _restApiService.GetWithNoParameter().Result; Console.WriteLine(result1); break; case 2: - var result2 = _restApiService.GetWithParameter(4); + var result2 = _restApiService.GetWithParameter(4).Result; Console.WriteLine(result2); break; case 3: - var result3 = _restApiService.PostWithTestObject(new ModelForTest()); + var result3 = _restApiService.PostWithTestObject(new ModelForTest()).Result; Console.WriteLine(result3); break; case 4: - var result4 = _restApiService.PutWithParameters(4, new ModelForTest()); + var result4 = _restApiService.PutWithParameters(4, new ModelForTest()).Result; Console.WriteLine(result4); break; case 5: - var result5 = _restApiService.DeleteWithParameters(5); + var result5 = _restApiService.DeleteWithParameters(5).Result; Console.WriteLine(result5); break; default: