Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions BusBoard.Api/BusBoard.Api.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>BusBoard.Api</RootNamespace>
<AssemblyName>BusBoard.Api</AssemblyName>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0-rc.1.25451.107" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="10.0.0-rc.1.25451.107" />
<PackageReference Include="RestSharp" Version="112.1.1-alpha.0.4" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using BusBoard.ConsoleApp.TflModels;
using Microsoft.Extensions.Configuration;
using BusBoard.Api.TflModels;
using RestSharp;
using RestSharp.Serializers.Json;

namespace BusBoard.ConsoleApp.PostcodeApiService;
namespace BusBoard.Api.PostcodeApiService;

public class PostcodeApiClient
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace BusBoard.ConsoleApp.PostcodeApiService;
namespace BusBoard.Api.PostcodeApiService;

using System.Text.Json.Serialization;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace BusBoard.ConsoleApp.TflApiService;
using BusBoard.ConsoleApp.TflModels;
namespace BusBoard.Api.TflApiService;
using BusBoard.Api.TflModels;


public class Actions
Expand Down Expand Up @@ -37,4 +37,10 @@ public List<StopPoint> GetStopsInRadiusOfLocation(double latitude, double longit

return predictions.StopPoints;
}

public StopPoint? GetStopPoint(string stopId)
{
var stopPoint = _tflApiClient.GetApiResponse<StopPoint>($"StopPoint/{stopId}");
return stopPoint;
}
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
using RestSharp;
using RestSharp.Serializers.Json;
using Microsoft.Extensions.Configuration;

namespace BusBoard.ConsoleApp.TflApiService;
namespace BusBoard.Api.TflApiService;

public class TflApiClient
{
private readonly RestClient _client;

public TflApiClient()
{
var config = new ConfigurationBuilder()
.AddUserSecrets<Program>()
.AddEnvironmentVariables()
.Build();

RestClientOptions options = new RestClientOptions("https://api.tfl.gov.uk/");
_client = new RestClient(
options,
configureSerialization: s => s.UseSystemTextJson());

string tflSecretKey = config["tflApi:key"];
if (string.IsNullOrWhiteSpace(tflSecretKey))
{
throw new Exception("Tfl API key not configured");
}

_client.AddDefaultParameter("app_key", tflSecretKey);
}

public T GetApiResponse<T>(string resource, Dictionary<string, string> queryOptions = null )
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace BusBoard.ConsoleApp.TflModels;
namespace BusBoard.Api.TflModels;
using System.Text.Json.Serialization;
public class Prediction
{
Expand Down
4 changes: 4 additions & 0 deletions BusBoard.ConsoleApp/BusBoard.ConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@
<PackageReference Include="RestSharp" Version="112.1.1-alpha.0.4" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BusBoard.Api\BusBoard.Api.csproj" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions BusBoard.ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Net;
using BusBoard.ConsoleApp.PostcodeApiService;
using BusBoard.ConsoleApp.TflApiService;
using BusBoard.ConsoleApp.TflModels;
using BusBoard.Api.PostcodeApiService;
using BusBoard.Api.TflApiService;
using BusBoard.Api.TflModels;
using System.Text.RegularExpressions;

public class Program
Expand Down
15 changes: 15 additions & 0 deletions BusBoard.Web/BusBoard.Web.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>BusBoard.Web</RootNamespace>
<AssemblyName>BusBoard.Web</AssemblyName>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\BusBoard.Api\BusBoard.Api.csproj" />
</ItemGroup>

</Project>
24 changes: 24 additions & 0 deletions BusBoard.Web/Content/Site.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
body {
padding-top: 50px;
padding-bottom: 20px;
}

/* Set padding to keep content from hitting the edges */
.body-content {
padding-left: 15px;
padding-right: 15px;
}

/* Override the default bootstrap behavior where horizontal description lists
will truncate terms that are too long to fit in the left column
*/
.dl-horizontal dt {
white-space: normal;
}

/* Set width on the form input elements since they're 100% wide by default */
input,
select,
textarea {
max-width: 280px;
}
Loading