BREAKING: DATABASE UPDATE; add comments; cleanup
This commit is contained in:
parent
14c0e506a4
commit
e5a7e8ec6c
|
@ -1,8 +1,8 @@
|
||||||
@page
|
@page
|
||||||
@using Microsoft.AspNetCore.Http
|
@using Microsoft.AspNetCore.Http
|
||||||
@using Microsoft.AspNetCore.Http.Extensions
|
@using Microsoft.AspNetCore.Http.Extensions
|
||||||
@using bahnplan.web.database
|
|
||||||
@using LinqToDB
|
@using LinqToDB
|
||||||
|
@using bahnplan.web.database
|
||||||
@model IndexModel
|
@model IndexModel
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Home";
|
ViewData["Title"] = "Home";
|
||||||
|
@ -27,6 +27,7 @@
|
||||||
<th scope="col">Origin</th>
|
<th scope="col">Origin</th>
|
||||||
<th scope="col">Via</th>
|
<th scope="col">Via</th>
|
||||||
<th scope="col">Destination</th>
|
<th scope="col">Destination</th>
|
||||||
|
<th scope="col">Comments</th>
|
||||||
<th scope="col">Actions</th>
|
<th scope="col">Actions</th>
|
||||||
<th scope="col">Danger zone</th>
|
<th scope="col">Danger zone</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -46,11 +47,14 @@
|
||||||
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);
|
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>
|
<tr>
|
||||||
<td>@Html.Raw(dates)</td>
|
<td>@Html.Raw(dates)</td>
|
||||||
<td>@Html.Raw(legs.First().DepStation.PadRight(30, ' ').Substring(0, 30).Replace(" ", " "))</td>
|
<td>@Html.Raw(legs.First().DepStation.PadRight(30, ' ').Substring(0, 30).TrimEnd())</td>
|
||||||
<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}"))
|
@((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}"))
|
||||||
</td>
|
</td>
|
||||||
<td>@Html.Raw(legs.Last().ArrStation.PadRight(30, ' ').Substring(0, 30).Replace(" ", " "))</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}"))
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a class="btn btn-sm btn-primary" href="/Trip?id=@trip.TripId">View</a>
|
<a class="btn btn-sm btn-primary" href="/Trip?id=@trip.TripId">View</a>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -16,6 +16,11 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Request.HasFormContentType) {
|
||||||
|
Response.Redirect(Request.GetEncodedUrl());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (Model.Legs.First().UserId != int.Parse(HttpContext.Session.GetString("uid"))) {
|
if (Model.Legs.First().UserId != int.Parse(HttpContext.Session.GetString("uid"))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -64,6 +69,7 @@
|
||||||
<th scope="col">Departure</th>
|
<th scope="col">Departure</th>
|
||||||
<th scope="col">Arrival</th>
|
<th scope="col">Arrival</th>
|
||||||
<th scope="col">Train</th>
|
<th scope="col">Train</th>
|
||||||
|
<th scope="col">Comment</th>
|
||||||
@if (!Request.Query.ContainsKey("edit")) {
|
@if (!Request.Query.ContainsKey("edit")) {
|
||||||
<th scope="col">Actions</th>
|
<th scope="col">Actions</th>
|
||||||
}
|
}
|
||||||
|
@ -79,6 +85,7 @@
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
<td></td>
|
||||||
@if (!Request.Query.ContainsKey("edit")) {
|
@if (!Request.Query.ContainsKey("edit")) {
|
||||||
<td></td>
|
<td></td>
|
||||||
}
|
}
|
||||||
|
@ -99,13 +106,18 @@
|
||||||
@date
|
@date
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<b>@dept</b> @Html.Raw(leg.DepStation.PadRight(30, ' ').Substring(0, 30).Replace(" ", " "))
|
<b>@dept</b> @Html.Raw(leg.DepStation.PadRight(30, ' ').Substring(0, 30).TrimEnd())
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<b>@arrt</b> @Html.Raw(leg.ArrStation.PadRight(30, ' ').Substring(0, 30).Replace(" ", " "))
|
<b>@arrt</b> @Html.Raw(leg.ArrStation.PadRight(30, ' ').Substring(0, 30).TrimEnd())
|
||||||
</td>
|
</td>
|
||||||
<td>@leg.TrainType @leg.TrainNr</td>
|
<td>@leg.TrainType @leg.TrainNr</td>
|
||||||
@if (!Request.Query.ContainsKey("edit")) {
|
@if (!Request.Query.ContainsKey("edit")) {
|
||||||
|
<td class="text-center">
|
||||||
|
@if (!string.IsNullOrWhiteSpace(leg.Comment)) {
|
||||||
|
@Html.Raw(leg.Comment)
|
||||||
|
}
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@if (leg.TicketId != 0) {
|
@if (leg.TicketId != 0) {
|
||||||
<a class="btn btn-sm btn-danger" href="/Inspection?id=@leg.TicketId&leg=@leg.LegId" target="_blank">Ticket</a>
|
<a class="btn btn-sm btn-danger" href="/Inspection?id=@leg.TicketId&leg=@leg.LegId" target="_blank">Ticket</a>
|
||||||
|
@ -118,6 +130,12 @@
|
||||||
</td>
|
</td>
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
<td>
|
||||||
|
<form method="POST">
|
||||||
|
<input type="hidden" name="id" value="@leg.LegId">
|
||||||
|
<input type="text" class="form-control" name="comment" value="@leg.Comment"/>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@{
|
@{
|
||||||
await using var db = new Database.DbConn();
|
await using var db = new Database.DbConn();
|
||||||
|
|
|
@ -37,5 +37,22 @@ namespace bahnplan.web.Pages {
|
||||||
|
|
||||||
Legs = db.Legs.Where(p => p.TripId == int.Parse(Request.Query["id"])).OrderBy(p => p.DepTime).ToList();
|
Legs = db.Legs.Where(p => p.TripId == int.Parse(Request.Query["id"])).OrderBy(p => p.DepTime).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnPost() {
|
||||||
|
if (HttpContext.Session.GetString("authorized") != "true")
|
||||||
|
return;
|
||||||
|
|
||||||
|
using var db = new Database.DbConn();
|
||||||
|
if (!Request.Form.ContainsKey("comment"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var leg = db.Legs.First(p => p.LegId == int.Parse(Request.Form["id"]));
|
||||||
|
if (leg.UserId != int.Parse(HttpContext.Session.GetString("uid")))
|
||||||
|
return;
|
||||||
|
|
||||||
|
leg.Comment = Request.Form["comment"];
|
||||||
|
|
||||||
|
db.Update(leg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Binary file not shown.
|
@ -22,20 +22,6 @@ CREATE TABLE IF NOT EXISTS "TicketLegs" (
|
||||||
"ArrStation" TEXT NOT NULL,
|
"ArrStation" TEXT NOT NULL,
|
||||||
"ArrTime" TEXT NOT NULL
|
"ArrTime" TEXT NOT NULL
|
||||||
);
|
);
|
||||||
CREATE TABLE IF NOT EXISTS "Legs" (
|
|
||||||
"LegID" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
|
||||||
"TripID" INTEGER NOT NULL,
|
|
||||||
"UserID" INTEGER NOT NULL,
|
|
||||||
"TrainType" TEXT NOT NULL,
|
|
||||||
"TrainNr" INTEGER NOT NULL,
|
|
||||||
"DepStationID" INTEGER NOT NULL,
|
|
||||||
"DepStation" TEXT NOT NULL,
|
|
||||||
"DepTime" TEXT NOT NULL,
|
|
||||||
"ArrStationID" INTEGER NOT NULL,
|
|
||||||
"ArrStation" TEXT NOT NULL,
|
|
||||||
"ArrTime" TEXT NOT NULL,
|
|
||||||
"TicketID" INTEGER
|
|
||||||
);
|
|
||||||
CREATE TABLE IF NOT EXISTS "Tickets" (
|
CREATE TABLE IF NOT EXISTS "Tickets" (
|
||||||
"TicketID" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
"TicketID" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||||
"UserID" INTEGER NOT NULL,
|
"UserID" INTEGER NOT NULL,
|
||||||
|
@ -63,11 +49,26 @@ CREATE TABLE IF NOT EXISTS "Cards" (
|
||||||
"QRValidTo" TEXT NOT NULL,
|
"QRValidTo" TEXT NOT NULL,
|
||||||
"QRValidFrom" TEXT NOT NULL
|
"QRValidFrom" TEXT NOT NULL
|
||||||
);
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS "Legs" (
|
||||||
|
"LegID" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||||
|
"TripID" INTEGER NOT NULL,
|
||||||
|
"UserID" INTEGER NOT NULL,
|
||||||
|
"TrainType" TEXT NOT NULL,
|
||||||
|
"TrainNr" INTEGER NOT NULL,
|
||||||
|
"DepStationID" INTEGER NOT NULL,
|
||||||
|
"DepStation" TEXT NOT NULL,
|
||||||
|
"DepTime" TEXT NOT NULL,
|
||||||
|
"ArrStationID" INTEGER NOT NULL,
|
||||||
|
"ArrStation" TEXT NOT NULL,
|
||||||
|
"ArrTime" TEXT NOT NULL,
|
||||||
|
"TicketID" INTEGER,
|
||||||
|
"Comment" TEXT
|
||||||
|
);
|
||||||
DELETE FROM sqlite_sequence;
|
DELETE FROM sqlite_sequence;
|
||||||
INSERT INTO sqlite_sequence VALUES('Trips',68);
|
INSERT INTO sqlite_sequence VALUES('Trips',68);
|
||||||
INSERT INTO sqlite_sequence VALUES('Users',55);
|
INSERT INTO sqlite_sequence VALUES('Users',55);
|
||||||
INSERT INTO sqlite_sequence VALUES('TicketLegs',10);
|
INSERT INTO sqlite_sequence VALUES('TicketLegs',10);
|
||||||
INSERT INTO sqlite_sequence VALUES('Legs',85);
|
|
||||||
INSERT INTO sqlite_sequence VALUES('Tickets',25);
|
INSERT INTO sqlite_sequence VALUES('Tickets',25);
|
||||||
INSERT INTO sqlite_sequence VALUES('Cards',10);
|
INSERT INTO sqlite_sequence VALUES('Cards',10);
|
||||||
|
INSERT INTO sqlite_sequence VALUES('Legs',0);
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
|
@ -29,5 +29,7 @@ namespace bahnplan.web.database.Tables {
|
||||||
[Column(Name = "ArrTime"), NotNull] public string ArrTime { get; set; }
|
[Column(Name = "ArrTime"), NotNull] public string ArrTime { get; set; }
|
||||||
|
|
||||||
[Column(Name = "TicketID")] public int TicketId { get; set; }
|
[Column(Name = "TicketID")] public int TicketId { get; set; }
|
||||||
|
|
||||||
|
[Column(Name = "Comment")] public string Comment { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -69,3 +69,7 @@ body {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
line-height: 60px; /* Vertically center the text there */
|
line-height: 60px; /* Vertically center the text there */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
vertical-align: middle !important;
|
||||||
|
}
|
Reference in a new issue