diff --git a/README.md b/README.md index 2e79308..2b328ba 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,10 @@ - Stuff WILL break - I am not responsible if some DB guy comes knocking on your doorstep if you use this or this software creates any kind of other damages - Most importantly: have fun. + +## Development / testing requirements +- .NET Core SDK (version 3.1.3 or higher; arch package `dotnet-sdk`) +- ASP.NET Core Runtime (version 3.1.3 or higher; arch package `aspnet-runtime`) + +- `cd bahnplan.web` +- `dotnet run` \ No newline at end of file diff --git a/bahnplan.web/Pages/Delete.cshtml b/bahnplan.web/Pages/Delete.cshtml index 1e96558..be6c22f 100644 --- a/bahnplan.web/Pages/Delete.cshtml +++ b/bahnplan.web/Pages/Delete.cshtml @@ -5,13 +5,51 @@ @model DeleteModel @{ ViewData["Title"] = "Home"; - - + if (HttpContext.Session.GetString("authorized") != "true") { Response.Redirect("/"); return; } - - Layout = null; - Response.Redirect(Request.Headers["Referer"]); + + if (Request.Query.ContainsKey("confirm") && Request.Query["confirm"] == "true") { + Layout = null; + Response.Redirect(Request.Headers["Referer"]); + } + + else { +

Are you sure?

+

+ You are attempting to delete + @{ + await using var db = new Database.DbConn(); + } + @switch (Request.Query["item"]) { + case "trip": { + var legs = db.Legs.Where(p => p.TripId == int.Parse(Request.Query["id"])).OrderBy(p => p.DepTime).ToList();; + + + the trip from @legs.First().DepStation to @legs.Last().ArrStation, starting @legs.First().DepTime + + break; + } + case "leg": { + Response.Redirect($"/Delete?item={Request.Query["item"]}&id={Request.Query["id"]}&confirm=true"); + break; + } + case "ticket": { + Response.Redirect($"/Delete?item={Request.Query["item"]}&id={Request.Query["id"]}&confirm=true"); + break; + } + case "card": { + var card = db.Cards.First(p => p.CardId == int.Parse(Request.Query["id"])); + + the card @card.CardInfo.TrimEnd('#') with the number @card.CardNumber, owned by @card.Traveller + + break; + } + } +

+ Cancel + Confirm + } } \ No newline at end of file diff --git a/bahnplan.web/Pages/Delete.cshtml.cs b/bahnplan.web/Pages/Delete.cshtml.cs index 47008e3..d0c58dc 100644 --- a/bahnplan.web/Pages/Delete.cshtml.cs +++ b/bahnplan.web/Pages/Delete.cshtml.cs @@ -18,6 +18,9 @@ namespace bahnplan.web.Pages { if (HttpContext.Session.GetString("authorized") != "true") return; + if (!Request.Query.ContainsKey("confirm") || Request.Query["confirm"] != "true") + return; + var uid = int.Parse(HttpContext.Session.GetString("uid")); using var db = new Database.DbConn(); AuthorizedUser = db.Users.FirstOrDefault(p => p.UserId == uid); diff --git a/bahnplan.web/Pages/Trip.cshtml.cs b/bahnplan.web/Pages/Trip.cshtml.cs index 68fe0a4..269bd30 100644 --- a/bahnplan.web/Pages/Trip.cshtml.cs +++ b/bahnplan.web/Pages/Trip.cshtml.cs @@ -9,14 +9,12 @@ using Microsoft.AspNetCore.Mvc.RazorPages; namespace bahnplan.web.Pages { public class TripModel : PageModel { public List Legs; - public Ticket Ticket; public void OnGet() { - if (HttpContext.Session.GetString("authorized") != "true") { return; } - + using var db = new Database.DbConn(); if (Request.Query.ContainsKey("separator")) { var leg = db.Legs.First(p => p.LegId == int.Parse(Request.Query["legid"])); @@ -35,15 +33,7 @@ namespace bahnplan.web.Pages { return; } - var legs = db.Legs.Where(p => p.TripId == int.Parse(Request.Query["id"])).ToList(); - Legs = new List(); - foreach (var j in legs) { - Legs.Add(j); - if (j.TicketId != 0) - Ticket = db.Tickets.First(p => p.TicketId == j.TicketId); - } - - Legs = Legs.OrderBy(p => p.DepTime).ToList(); + Legs = db.Legs.Where(p => p.TripId == int.Parse(Request.Query["id"])).OrderBy(p => p.DepTime).ToList(); } } } \ No newline at end of file