-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
904c677
commit a57a5ce
Showing
18 changed files
with
418 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
SELECT s.Date, | ||
a.Name AS "Airline", | ||
f.Number, | ||
f.Embarkation, | ||
f.Destination, | ||
ac.Registration, | ||
m.Name AS "Model", | ||
ma.Name AS "Manufacturer" | ||
FROM SIGHTING s | ||
INNER JOIN FLIGHT f on f.Id = s.Flight_Id | ||
INNER JOIN AIRLINE a on a.Id = f.Airline_Id | ||
INNER JOIN AIRCRAFT ac ON ac.Id = s.Aircraft_Id | ||
INNER JOIN MODEL m ON m.Id = ac.Model_Id | ||
INNER JOIN MANUFACTURER ma ON ma.Id = m.Manufacturer_Id | ||
WHERE s.Is_My_Flight = 1 | ||
AND s.Date BETWEEN '$from' AND '$to' | ||
ORDER BY s.Date; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using FlightRecorder.Entities.Attributes; | ||
using Microsoft.EntityFrameworkCore; | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace FlightRecorder.Entities.Reporting | ||
{ | ||
[Keyless] | ||
[ExcludeFromCodeCoverage] | ||
public class MyFlights | ||
{ | ||
[Export("Date", 1)] | ||
public DateTime Date { get; set; } | ||
|
||
[Export("Airline", 2)] | ||
public string Airline { get; set; } | ||
|
||
[Export("Number", 3)] | ||
public string Number { get; set; } | ||
|
||
[Export("Embarkation", 4)] | ||
public string Embarkation { get; set; } | ||
|
||
[Export("Destination", 5)] | ||
public string Destination { get; set; } | ||
|
||
[Export("Registration", 6)] | ||
public string Registration { get; set; } | ||
|
||
[Export("Model", 7)] | ||
public string Model { get; set; } | ||
|
||
[Export("Manufacturer", 7)] | ||
public string Manufacturer { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using FlightRecorder.Mvc.Api; | ||
using FlightRecorder.Mvc.Configuration; | ||
using FlightRecorder.Mvc.Entities; | ||
using FlightRecorder.Mvc.Models; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace FlightRecorder.Mvc.Controllers | ||
{ | ||
public class MyFlightsController : Controller | ||
{ | ||
private readonly ReportsClient _reportsClient; | ||
private readonly ExportClient _exportClient; | ||
private readonly IOptions<AppSettings> _settings; | ||
|
||
public MyFlightsController( | ||
ReportsClient reportsClient, | ||
ExportClient exportsClient, | ||
IOptions<AppSettings> settings) | ||
{ | ||
_reportsClient = reportsClient; | ||
_exportClient = exportsClient; | ||
_settings = settings; | ||
} | ||
|
||
/// <summary> | ||
/// Serve the empty report page | ||
/// </summary> | ||
/// <returns></returns> | ||
[HttpGet] | ||
public IActionResult Index() | ||
{ | ||
MyFlightsViewModel model = new MyFlightsViewModel | ||
{ | ||
PageNumber = 1 | ||
}; | ||
return View(model); | ||
} | ||
|
||
/// <summary> | ||
/// Respond to a POST event triggering the report generation | ||
/// </summary> | ||
/// <param name="model"></param> | ||
/// <returns></returns> | ||
[HttpPost] | ||
[ValidateAntiForgeryToken] | ||
public async Task<IActionResult> Index(MyFlightsViewModel model) | ||
{ | ||
if (ModelState.IsValid) | ||
{ | ||
int page = model.PageNumber; | ||
switch (model.Action) | ||
{ | ||
case ControllerActions.ActionPreviousPage: | ||
page -= 1; | ||
break; | ||
case ControllerActions.ActionNextPage: | ||
page += 1; | ||
break; | ||
case ControllerActions.ActionSearch: | ||
page = 1; | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
// Need to clear model state here or the page number that was posted | ||
// is returned and page navigation doesn't work correctly. So, capture | ||
// and amend the page number, above, then apply it, below | ||
ModelState.Clear(); | ||
|
||
DateTime start = !string.IsNullOrEmpty(model.From) ? DateTime.Parse(model.From) : DateTime.MinValue; | ||
DateTime end = !string.IsNullOrEmpty(model.To) ? DateTime.Parse(model.To) : DateTime.MaxValue; | ||
|
||
List<MyFlights> records = await _reportsClient.MyFlightsAsync(start, end, page, _settings.Value.SearchPageSize); | ||
model.SetRecords(records, page, _settings.Value.SearchPageSize); | ||
} | ||
|
||
return View(model); | ||
} | ||
|
||
/// <summary> | ||
/// Request export of the report | ||
/// </summary> | ||
/// <param name="model"></param> | ||
/// <returns></returns> | ||
[HttpPost] | ||
public async Task<IActionResult> Export([FromBody] MyFlightsViewModel model) | ||
{ | ||
await _exportClient.ExportReport<MyFlights>(model); | ||
return Ok(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace FlightRecorder.Mvc.Entities | ||
{ | ||
public class MyFlights | ||
{ | ||
public DateTime Date { get; set; } | ||
public string Airline { get; set; } | ||
public string Number { get; set; } | ||
public string Embarkation { get; set; } | ||
public string Destination { get; set; } | ||
public string Registration { get; set; } | ||
public string Model { get; set; } | ||
public string Manufacturer { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using FlightRecorder.Mvc.Entities; | ||
|
||
namespace FlightRecorder.Mvc.Models | ||
{ | ||
public class MyFlightsViewModel : DateBasedReportViewModelBase<MyFlights> | ||
{ | ||
} | ||
} |
Oops, something went wrong.