Skip to content

Commit

Permalink
Merge branch 'master' into feature/add-utc-display
Browse files Browse the repository at this point in the history
  • Loading branch information
rickduggan authored Aug 2, 2024
2 parents 6efb05d + 5e8ef1b commit 054bd88
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions DepartureBoardWeb/Controllers/StationLookupController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,21 @@ public JsonResult GetStationCodeFromName(string name)

return Json(string.Empty);
}

[HttpGet("[action]")]
public JsonResult GetStationInfoFromCode(string code = "")
{
code = code.ToUpper();
var station = _stationLookup.Stations?.FirstOrDefault(s => s.Code == code);

// Get timezone for the UK
var offset = TimeZoneInfo.ConvertTime(DateTimeOffset.Now, TimeZoneInfo.FindSystemTimeZoneById("GB")).Offset.Hours;

return Json(new
{
name = station?.Name ?? code,
utcOffset = offset
});
}
}
}

0 comments on commit 054bd88

Please sign in to comment.