-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrivalsList.cs
More file actions
43 lines (38 loc) · 1.17 KB
/
ArrivalsList.cs
File metadata and controls
43 lines (38 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using RestSharp;
using System.Linq;
namespace BusBoard
{
public class ArrivalsList
{
public static List<Arrivals> ArrivalsFetcher(string stopSearchUrl)
{
var client = new RestClient(stopSearchUrl);
client.Timeout = -1;
var request = new RestRequest(Method.GET);
var response = client.Get<List<Arrivals>>(request);
return response.Data;
}
public static string ArrivalsBoard(List<Arrivals> arrivals)
{
string arrivalsBoard = "";
foreach (var arrival in arrivals)
{
int minutes = arrival.TimeToStation / 60;
string min;
if (minutes < 1)
{
min = " min";
}
else
{
min = " mins";
}
string arrivalEntry = string.Format(("{0,2}{1,-10}{2,-9}{3,-4}\n"), minutes, min, arrival.LineName, arrival.DestinationName);
arrivalsBoard += arrivalEntry;
}
return arrivalsBoard;
}
}
}