From 7699064cfd4219f2bdb9bf63f70b7fcafca5d719 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Tue, 24 Aug 2021 20:56:52 +0200 Subject: [PATCH] Bugfix --- bahnplan.web/Pages/Delete.cshtml.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bahnplan.web/Pages/Delete.cshtml.cs b/bahnplan.web/Pages/Delete.cshtml.cs index 3bb8a5c..46fd30d 100644 --- a/bahnplan.web/Pages/Delete.cshtml.cs +++ b/bahnplan.web/Pages/Delete.cshtml.cs @@ -46,6 +46,22 @@ namespace bahnplan.web.Pages { db.Delete(db.Legs.Where(p => p.TripId == tripid).OrderBy(p => p.DepTime).First()); else if (db.Legs.Where(p => p.TripId == tripid).OrderByDescending(p => p.DepTime).First().DepTime.EndsWith("placeholder")) db.Delete(db.Legs.Where(p => p.TripId == tripid).OrderByDescending(p => p.DepTime).First()); + + var failsafe = false; + foreach (var failsafeleg in db.Legs.Where(p => p.TripId == tripid).OrderBy(p => p.DepTime).ToList()) { + if (failsafeleg.DepTime.EndsWith("placeholder")) { + if (failsafe == false) { + failsafe = true; + } + else { + db.Legs.Delete(p => p.LegId == failsafeleg.LegId); + } + } + else { + failsafe = false; + } + } + break; } case "ticket": {