Skip to content

Commit

Permalink
POC work is done here
Browse files Browse the repository at this point in the history
  • Loading branch information
NakWarsi committed Nov 13, 2019
1 parent a089ce1 commit 0d58d50
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions ApiApplication/RestApiforTest/Controllers/ValuesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public class ValuesController : ControllerBase
{
// GET api/values
[HttpGet]
public ActionResult<IEnumerable<string>> Get()
public ActionResult<string> Get()
{
return new string[] { "value1", "value2" };
return "Get Api with no argument was Called";
}

// GET api/values/5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace LibraryWithSDKandRefitService
public interface IRestService
{
[Get("/api/values")]
Task<IEnumerable<string>> GetWithNoParameter();
Task<string> GetWithNoParameter();

[Get("/api/values/{id}")]
Task<string> GetWithParameter([AliasAs("id")] int id);
Expand Down
17 changes: 8 additions & 9 deletions samples/ConsoleSampleUsingLocalApi/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using LibraryWithSDKandRefitService;
Expand All @@ -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<IRestService>(_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:
Expand Down

0 comments on commit 0d58d50

Please sign in to comment.