This repository has been archived on 2023-04-02. You can view files and clone it, but cannot push or open issues or pull requests.
trainav/trainav.web/Pages/SharedTrip.cshtml

81 lines
2.6 KiB
Plaintext

@page
@using trainav.web.Utils
@model SharedTripModel
@{
ViewData["Title"] = "Shared Trip";
if (Model.RedirToIndex) {
Response.Redirect("/");
return;
}
if (!Model.Legs.Any()) {
Response.Redirect("/");
return;
}
var dep = Model.Legs.First().DepStation;
var arr = Model.Legs.Last().ArrStation;
}
<div>
<p>
@Model.User's Trip from <b>@dep</b> to <b>@arr</b>, starting @DateTime.Parse(Model.Legs.First().DepTime).ToString("yyyy-MM-dd HH:mm")
</p>
</div>
<div>
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Date</th>
<th scope="col">Departure</th>
<th scope="col">Arrival</th>
<th scope="col">Train</th>
<th scope="col">Comment</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
@foreach (var leg in Model.Legs) {
if (leg.TrainType == "placeholder") {
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
continue;
}
var deptime = DateTime.Parse(leg.DepTime);
var arrtime = DateTime.Parse(leg.ArrTime);
var date = DateTime.Parse(leg.DepTime).ToString("ddd, dd.MM.");
var dept = deptime.ToString("HH:mm");
var arrt = arrtime.ToString("HH:mm");
<tr>
<td>
@date
</td>
<td>
<b>@dept</b> @Html.Raw(leg.DepStation.Delimit(35))
</td>
<td>
<b>@arrt</b> @Html.Raw(leg.ArrStation.Delimit(35))
</td>
<td>@leg.TrainType @leg.TrainNr</td>
<td>
@if (!string.IsNullOrWhiteSpace(leg.Comment)) {
@Html.Raw(leg.Comment)
}
</td>
<td>
<a class="btn btn-sm btn-primary" href="https://bahn.expert/details/@leg.TrainType @leg.TrainNr/@(deptime.ToUniversalTime().Subtract(new DateTime(1970, 1, 1)).TotalSeconds)000/?station=@leg.DepStationId" target="_blank">BahnExpert</a>
<a class="btn btn-sm btn-warning" href="https://travelynx.de/s/@leg.DepStationId?train=@leg.TrainType @leg.TrainNr" target="_blank">Travelynx</a>
</td>
</tr>
}
</tbody>
</table>
</div>
<a class="btn btn-sm btn-primary" href="/GenIcs?id=@Request.Query["id"]&user=@Model.User">Download ICS</a>