From c68e923c105e2d99753f6aa97be2fd9d832e7ee2 Mon Sep 17 00:00:00 2001 From: Per Date: Wed, 7 Apr 2021 20:46:51 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20for=20#110=20-=20der=20skal=20kun=20v?= =?UTF-8?q?=C3=A6re=20uddannelsesflyvninger=20(mindst=201=20grading)=20p?= =?UTF-8?q?=C3=A5=20listen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/TrainingLogHistoryController.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/FlightJournal.Web/Controllers/TrainingLogHistoryController.cs b/FlightJournal.Web/Controllers/TrainingLogHistoryController.cs index 60cfccd6..0b42498e 100644 --- a/FlightJournal.Web/Controllers/TrainingLogHistoryController.cs +++ b/FlightJournal.Web/Controllers/TrainingLogHistoryController.cs @@ -154,12 +154,15 @@ public ActionResult ExportToJson(DateTime? fromDate, DateTime? toDate) private IEnumerable SelectFlights(DateTime fromDate, DateTime toDate) { IEnumerable flights; - var flightIds = db.AppliedExercises.Select(x => x.FlightId).Union(db.TrainingFlightAnnotations.Select(y => y.FlightId)).Distinct().ToList(); + var trainingFlightIds = db.AppliedExercises + .Where(x=>x.Grading != null) + .Select(x => x.FlightId) + .Distinct().ToList(); switch (UsersAccessScope()) { case AccessScope.AllFlights: - flights = db.Flights.Where(x => x.Date >= fromDate && x.Date <= toDate && flightIds.Contains(x.FlightId)); + flights = db.Flights.Where(x => x.Date >= fromDate && x.Date <= toDate && trainingFlightIds.Contains(x.FlightId)); if (ClubController.CurrentClub.ShortName != null) { flights = flights.Where(f => @@ -172,7 +175,7 @@ private IEnumerable SelectFlights(DateTime fromDate, DateTime toDate) break; case AccessScope.OwnFlights: var pilotId = Request.Pilot().PilotId; - flights = db.Flights.Where(x => x.Date >= fromDate && x.Date <= toDate && flightIds.Contains(x.FlightId) && (x.PilotId == pilotId || x.PilotBackseatId == pilotId)); + flights = db.Flights.Where(x => x.Date >= fromDate && x.Date <= toDate && trainingFlightIds.Contains(x.FlightId) && (x.PilotId == pilotId || x.PilotBackseatId == pilotId)); break; default: flights = Enumerable.Empty();