179 lines
7.4 KiB
Plaintext
179 lines
7.4 KiB
Plaintext
@page
|
|
@using bahnplan.web.database
|
|
@using Microsoft.AspNetCore.Http
|
|
@model TripModel
|
|
@{
|
|
ViewData["Title"] = "Trip";
|
|
|
|
if (HttpContext.Session.GetString("authorized") != "true") {
|
|
Response.Redirect("/");
|
|
return;
|
|
}
|
|
|
|
if (Request.Query.ContainsKey("separator")) {
|
|
Response.Redirect(Request.Headers["Referer"]);
|
|
return;
|
|
}
|
|
var dep = Model.Legs.First().DepStation;
|
|
var arr = Model.Legs.Last().ArrStation;
|
|
var deplenmax = Model.Legs.Max(p => p.DepStation.Length) + 1;
|
|
var arrlenmax = Model.Legs.Max(p => p.ArrStation.Length) + 1;
|
|
}
|
|
|
|
<div>
|
|
<p>
|
|
Your Trip from <b>@dep</b> to <b>@arr</b>, starting @DateTime.Parse(Model.Legs.First().DepTime).ToString("yyyy-MM-dd HH:mm")
|
|
</p>
|
|
|
|
<code>
|
|
@foreach (var leg in Model.Legs) {
|
|
if (leg.TrainType == "placeholder") {
|
|
<div>
|
|
... ..:.. ... - ... ... - ..:.. ...
|
|
</div>
|
|
continue;
|
|
}
|
|
var deptime = DateTime.Parse(leg.DepTime);
|
|
var arrtime = DateTime.Parse(leg.ArrTime);
|
|
var date = DateTime.Parse(leg.DepTime).ToString("dd.MM.");
|
|
var dept = date + " " + deptime.ToString("HH:mm");
|
|
var depst = leg.DepStation.PadRight(20, ' ').Substring(0, 20).Replace(" ", " ");
|
|
var arrt = arrtime.ToString("HH:mm");
|
|
var arrst = leg.ArrStation.PadRight(20, ' ').Substring(0, 20).Replace(" ", " ");
|
|
var line = leg.TrainType.PadLeft(5).Replace(" ", " ") + " " + leg.TrainNr.ToString().PadRight(5).Replace(" ", " ");
|
|
<div>
|
|
@dept @Html.Raw(depst) - @Html.Raw(line) - @arrt @Html.Raw(arrst)
|
|
</div>
|
|
}
|
|
</code>
|
|
</div>
|
|
|
|
<br/>
|
|
|
|
<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>
|
|
@if (!Request.Query.ContainsKey("edit")) {
|
|
<th scope="col">Actions</th>
|
|
}
|
|
else {
|
|
<th scope="col">Danger zone</th>
|
|
}
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var leg in Model.Legs) {
|
|
if (leg.TrainType == "placeholder") {
|
|
<td></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td></td>
|
|
@if (!Request.Query.ContainsKey("edit")) {
|
|
<td></td>
|
|
}
|
|
else {
|
|
<td>
|
|
<a class="btn btn-sm btn-outline-danger" href="/Delete?item=leg&id=@leg.LegId">- Separator</a>
|
|
</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.PadRight(30, ' ').Substring(0, 30).Replace(" ", " "))
|
|
</td>
|
|
<td>
|
|
<b>@arrt</b> @Html.Raw(leg.ArrStation.PadRight(30, ' ').Substring(0, 30).Replace(" ", " "))
|
|
</td>
|
|
<td>@leg.TrainType @leg.TrainNr</td>
|
|
@if (!Request.Query.ContainsKey("edit")) {
|
|
<td>
|
|
@if (leg.TicketId != 0) {
|
|
<a class="btn btn-sm btn-danger" href="/Inspection?id=@leg.TicketId&leg=@leg.LegId" target="_blank">Ticket</a>
|
|
}
|
|
else {
|
|
<a class="btn btn-sm btn-danger disabled">Ticket</a>
|
|
}
|
|
<a class="btn btn-sm btn-primary" href="https://marudor.de/details/@leg.TrainType @leg.TrainNr/@(deptime.ToUniversalTime().Subtract(new DateTime(1970, 1, 1)).TotalSeconds)000/?station=@leg.DepStationId">Marudor</a>
|
|
<a class="btn btn-sm btn-warning" href="https://travelynx.de/s/@leg.DepStationId?train=@leg.TrainType @leg.TrainNr">Travelynx</a>
|
|
</td>
|
|
}
|
|
else {
|
|
<td>
|
|
@{
|
|
await using var db = new Database.DbConn();
|
|
if (!db.Legs.Any(p => p.DepTime == leg.DepTime + "_placeholder")) {
|
|
<a class="btn btn-sm btn-outline-secondary" href="?separator=true&legid=@leg.LegId&id=@leg.TripId">+ Separator</a>
|
|
}
|
|
else {
|
|
<a class="btn btn-sm btn-outline-secondary disabled" href="?separator=true&legid=@leg.LegId&id=@leg.TripId">+ Separator</a>
|
|
}
|
|
|
|
}
|
|
<a class="btn btn-sm btn-outline-danger" href="/Delete?item=leg&id=@leg.LegId">- Leg</a>
|
|
@if (leg.TicketId != 0) {
|
|
<a class="btn btn-sm btn-outline-danger" href="/Delete?item=ticket&id=@leg.LegId">- Ticket</a>
|
|
}
|
|
else {
|
|
<a class="btn btn-sm btn-outline-danger disabled">- Ticket</a>
|
|
}
|
|
</td>
|
|
}
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
@if (!Request.Query.ContainsKey("edit")) {
|
|
<a class="btn btn-sm btn-secondary" href="/Trip?id=@Request.Query["id"]&edit=true">Edit Trip</a>
|
|
}
|
|
else {
|
|
<a class="btn btn-sm btn-secondary" href="/Trip?id=@Request.Query["id"]">Back</a>
|
|
<br/>
|
|
<br/>
|
|
<div class="d-flex flex-row" style="justify-content: space-between">
|
|
<div class="d-flex p-2" style="width: 40%">
|
|
<form style="width: 100%" method="GET" action="/Ticket">
|
|
<h3>Add leg(s) from ticket</h3>
|
|
<br/>
|
|
<input type="hidden" name="action" value="addleg">
|
|
<input type="hidden" name="tripid" value="@Request.Query["id"]">
|
|
<div class="form-group">
|
|
<input type="text" class="form-control" name="order" placeholder="bahn.de order #">
|
|
</div>
|
|
<div class="form-group">
|
|
<input type="text" class="form-control" name="name" placeholder="Last name of traveller">
|
|
</div>
|
|
<br/>
|
|
<button type="submit" class="btn btn-primary">Submit</button>
|
|
</form>
|
|
</div>
|
|
<div class="d-flex p-2" style="width: 40%">
|
|
<form style="width: 100%" method="GET" action="/OEAPI">
|
|
<h3>Add leg(s) from oeffisear.ch</h3>
|
|
<br/>
|
|
<input type="hidden" name="action" value="addleg">
|
|
<input type="hidden" name="tripid" value="@Request.Query["id"]">
|
|
<div class="form-group">
|
|
<input type="text" class="form-control" name="link" placeholder="oeffisear.ch link / shortcode">
|
|
</div>
|
|
<br/>
|
|
<button type="submit" class="btn btn-primary">Submit</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
} |