-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
124 additions
and
171 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 24 additions & 28 deletions
52
src/CT.Common/Dto/GeoLocation.cs → src/CT.Common/Models/GeoLocation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,24 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace CT.Common.Dto | ||
{ | ||
|
||
public class GeoLocation | ||
{ | ||
|
||
public double lon { get; set; } | ||
|
||
public double lat { get; set; } | ||
|
||
public GeoLocation() | ||
{ | ||
|
||
} | ||
|
||
public GeoLocation(double lon, double lat) | ||
{ | ||
this.lat = lat; | ||
this.lon = lon; | ||
} | ||
|
||
} | ||
|
||
} | ||
namespace CT.Common.Models | ||
{ | ||
|
||
public class GeoLocation | ||
{ | ||
|
||
public double lon { get; set; } | ||
|
||
public double lat { get; set; } | ||
|
||
public GeoLocation() | ||
{ | ||
|
||
} | ||
|
||
public GeoLocation(double lon, double lat) | ||
{ | ||
this.lat = lat; | ||
this.lon = lon; | ||
} | ||
|
||
} | ||
|
||
} |
74 changes: 36 additions & 38 deletions
74
src/CT.Service/RestService.cs → src/CT.Service/AirportService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,36 @@ | ||
using CT.Common; | ||
using CT.Service.Dto; | ||
using System; | ||
using System.Net.Http; | ||
using System.Net.Http.Headers; | ||
using System.Threading.Tasks; | ||
|
||
namespace CT.Service | ||
{ | ||
|
||
public class RestService | ||
{ | ||
|
||
private readonly HttpClient _client; | ||
|
||
public RestService(HttpClient client) | ||
{ | ||
_client = client; | ||
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); | ||
} | ||
|
||
/// <summary> | ||
/// Airports are identified by 3-letter IATA code. | ||
/// </summary> | ||
/// <param name="code">IATA code.</param> | ||
/// <returns></returns> | ||
public virtual async Task<AirportItem> GetAirport(string code) | ||
{ | ||
var response = await _client.GetAsync($"/airports/{code}"); | ||
|
||
response.EnsureSuccessStatusCode(); | ||
|
||
return await response.Content.ReadAsAsync<AirportItem>(); | ||
} | ||
|
||
} | ||
|
||
} | ||
using System.Net.Http; | ||
using System.Net.Http.Headers; | ||
using System.Threading.Tasks; | ||
using CT.Service.Dtos; | ||
|
||
namespace CT.Service | ||
{ | ||
|
||
public class AirportService | ||
{ | ||
|
||
private readonly HttpClient _client; | ||
|
||
public AirportService(HttpClient client) | ||
{ | ||
_client = client; | ||
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); | ||
} | ||
|
||
/// <summary> | ||
/// Airports are identified by 3-letter IATA code. | ||
/// </summary> | ||
/// <param name="code">IATA code.</param> | ||
/// <returns></returns> | ||
public virtual async Task<AirportDto> GetAirport(string code) | ||
{ | ||
var response = await _client.GetAsync($"/airports/{code}"); | ||
|
||
response.EnsureSuccessStatusCode(); | ||
|
||
return await response.Content.ReadAsAsync<AirportDto>(); | ||
} | ||
|
||
} | ||
|
||
} |
62 changes: 31 additions & 31 deletions
62
src/CT.Service/Entities/AirportItem.cs → src/CT.Service/Dtos/AirportDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
using CT.Common.Dto; | ||
|
||
namespace CT.Service.Dto | ||
{ | ||
public class AirportItem | ||
{ | ||
|
||
public string country { get; set; } | ||
|
||
public string city_iata { get; set; } | ||
|
||
public string iata { get; set; } | ||
|
||
public string city { get; set; } | ||
|
||
public string timezone_region_name { get; set; } | ||
|
||
public string country_iata { get; set; } | ||
|
||
public int rating { get; set; } | ||
|
||
public string name { get; set; } | ||
|
||
public GeoLocation location { get; set; } | ||
|
||
public string type { get; set; } | ||
|
||
public int hubs { get; set; } | ||
} | ||
|
||
} | ||
using CT.Common.Models; | ||
|
||
namespace CT.Service.Dtos | ||
{ | ||
public class AirportDto | ||
{ | ||
|
||
public string country { get; set; } | ||
|
||
public string city_iata { get; set; } | ||
|
||
public string iata { get; set; } | ||
|
||
public string city { get; set; } | ||
|
||
public string timezone_region_name { get; set; } | ||
|
||
public string country_iata { get; set; } | ||
|
||
public int rating { get; set; } | ||
|
||
public string name { get; set; } | ||
|
||
public GeoLocation location { get; set; } | ||
|
||
public string type { get; set; } | ||
|
||
public int hubs { get; set; } | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.