redesign Index page

This commit is contained in:
Laura Hausmann 2020-06-15 14:02:54 +02:00
parent b443f2125b
commit 10bb5b41fb
Signed by: zotan
GPG key ID: 5EC1D38FFC321311
2 changed files with 16 additions and 12 deletions

View file

@ -23,13 +23,11 @@
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Date</th>
<th scope="col">Origin</th>
<th scope="col">Via</th>
<th scope="col">Destination</th>
<th scope="col">Comments</th>
<th scope="col">Actions</th>
<th scope="col">Danger zone</th>
</tr>
</thead>
<tbody>
@ -44,22 +42,27 @@
foreach (var trip in trips.OrderBy(p => db.Legs.First(a => a.TripId == p.TripId).DepTime)) {
var legs = db.Legs.Where(p => p.TripId == trip.TripId).OrderBy(p => p.DepTime).ToList();
var dates = DateTime.Parse(legs.First().DepTime).Date == DateTime.Parse(legs.Last().DepTime).Date ? legs.First().DepTime.Substring(0, 10) : legs.First().DepTime.Substring(0, 10) + "<br/>" + legs.Last().DepTime.Substring(0, 10);
<tr>
<td>@Html.Raw(dates)</td>
<td>@Html.Raw(legs.First().DepStation.PadRight(30, ' ').Substring(0, 30).TrimEnd())</td>
<td>
@((from index in from leg in legs where leg.TrainType == "placeholder" select legs.IndexOf(leg) select legs[index - 1].ArrStation).ToList().DefaultIfEmpty("-").Aggregate((s1, s2) => $"{s1}, {s2}"))
<b>@legs.First().DepStation.Delimit(30)</b>
<br/>
<small>@DateTime.Parse(legs.First().DepTime).ToString("ddd dd.MM.yyyy, HH:mm")</small>
</td>
<td>@Html.Raw(legs.Last().ArrStation.PadRight(30, ' ').Substring(0, 30).TrimEnd())</td>
<td>
@Html.Raw(legs.Where(leg => !string.IsNullOrWhiteSpace(leg.Comment)).Select(p => p.Comment).DefaultIfEmpty("").Aggregate((s1, s2) => $"{s1}<br/>{s2}"))
@((from index in from leg in legs where leg.TrainType == "placeholder" select legs.IndexOf(leg) select legs[index - 1].ArrStation.Delimit(30)).ToList().DefaultIfEmpty("-").Aggregate((s1, s2) => $"{s1}, {s2}"))
</td>
<td>
<b>@legs.Last().ArrStation.Delimit(30)</b>
<br/>
<small>@DateTime.Parse(legs.Last().DepTime).ToString("ddd dd.MM.yyyy, HH:mm")</small>
</td>
<td>
@Html.Raw(legs.Where(leg => !string.IsNullOrWhiteSpace(leg.Comment)).Select(p => p.Comment.Replace(", ", "<br/>")).DefaultIfEmpty("").Aggregate((s1, s2) => $"{s1}<br/>{s2}"))
</td>
<td>
<a class="btn btn-sm btn-primary" href="/Trip?id=@trip.TripId">View</a>
</td>
<td>
<a class="btn btn-sm btn-outline-danger" href="/Delete?item=trip&id=@trip.TripId&redir=@Request.GetDisplayUrl().UrlEncode()">Delete Trip</a>
&nbsp;
<a class="btn btn-sm btn-outline-danger" href="/Delete?item=trip&id=@trip.TripId&redir=@Request.GetDisplayUrl().UrlEncode()">Delete</a>
</td>
</tr>
}

View file

@ -47,6 +47,7 @@ namespace bahnplan.web.Pages {
return Convert.ToBase64String(plainTextBytes);
}
public static string UrlEncode(this string plainText) => HttpUtility.UrlEncode(plainText);
public static string UrlEncode(this string plainText) => HttpUtility.UrlEncode(plainText);
public static string Delimit(this string input, int max) => input.PadRight(max, ' ').Substring(0, max).TrimEnd();
}
}