Skip to content

Commit

Permalink
Merge pull request #28 from davewalker5/FR-114-Aircraft-Editing-Bug
Browse files Browse the repository at this point in the history
FR-114 Aircraft editing bug
  • Loading branch information
davewalker5 committed Dec 11, 2023
2 parents c52fd5a + 960bd87 commit 0c2381c
Show file tree
Hide file tree
Showing 26 changed files with 84 additions and 143 deletions.
4 changes: 2 additions & 2 deletions docker/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/core/aspnet:latest
COPY flightrecorder.api-1.7.0.0 /opt/flightrecorder.api-1.7.0.0
WORKDIR /opt/flightrecorder.api-1.7.0.0/bin
COPY flightrecorder.api-1.8.0.0 /opt/flightrecorder.api-1.8.0.0
WORKDIR /opt/flightrecorder.api-1.8.0.0/bin
ENTRYPOINT [ "./FlightRecorder.Api" ]
4 changes: 2 additions & 2 deletions docker/ui/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:latest AS runtime
COPY flightrecorder.mvc-1.6.0.0 /opt/flightrecorder.mvc-1.6.0.0
WORKDIR /opt/flightrecorder.mvc-1.6.0.0/bin
COPY flightrecorder.mvc-1.8.0.0 /opt/flightrecorder.mvc-1.8.0.0
WORKDIR /opt/flightrecorder.mvc-1.8.0.0/bin
ENTRYPOINT [ "./FlightRecorder.Mvc" ]
30 changes: 20 additions & 10 deletions src/FlightRecorder.Api/Controllers/AircraftController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
using FlightRecorder.Entities.Db;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;

namespace FlightRecorder.Api.Controllers
Expand Down Expand Up @@ -68,8 +65,12 @@ public async Task<ActionResult<Aircraft>> GetAircraftByRegistrationAsync(string
}

// TODO : This logic should be in the business logic
await _factory.Context.Entry(aircraft).Reference(a => a.Model).LoadAsync();
await _factory.Context.Entry(aircraft.Model).Reference(m => m.Manufacturer).LoadAsync();
// Load the model and manufacturer, if specified
if (aircraft.ModelId != null)
{
await _factory.Context.Entry(aircraft).Reference(a => a.Model).LoadAsync();
await _factory.Context.Entry(aircraft.Model).Reference(m => m.Manufacturer).LoadAsync();
}

return aircraft;
}
Expand All @@ -86,8 +87,12 @@ public async Task<ActionResult<Aircraft>> GetAircraftByIdAsync(int id)
}

// TODO : This logic should be in the business logic
await _factory.Context.Entry(aircraft).Reference(a => a.Model).LoadAsync();
await _factory.Context.Entry(aircraft.Model).Reference(m => m.Manufacturer).LoadAsync();
// Load the model and manufacturer, if specified
if (aircraft.ModelId != null)
{
await _factory.Context.Entry(aircraft).Reference(a => a.Model).LoadAsync();
await _factory.Context.Entry(aircraft.Model).Reference(m => m.Manufacturer).LoadAsync();
}

return aircraft;
}
Expand Down Expand Up @@ -122,8 +127,13 @@ public async Task<ActionResult<Aircraft>> UpdateAircraftAsync([FromBody] Aircraf
aircraft.Manufactured = (template.Manufactured > 0) ? template.Manufactured : null;
aircraft.ModelId = template.ModelId;
await _factory.Context.SaveChangesAsync();
await _factory.Context.Entry(aircraft).Reference(a => a.Model).LoadAsync();
await _factory.Context.Entry(aircraft.Model).Reference(m => m.Manufacturer).LoadAsync();

// Load the model and manufacturer, if specified
if (aircraft.ModelId != null)
{
await _factory.Context.Entry(aircraft).Reference(a => a.Model).LoadAsync();
await _factory.Context.Entry(aircraft.Model).Reference(m => m.Manufacturer).LoadAsync();
}

return aircraft;
}
Expand All @@ -137,7 +147,7 @@ public async Task<ActionResult<Aircraft>> CreateAircraftAsync([FromBody] Aircraf
Aircraft aircraft = await _factory.Aircraft
.AddAsync(template.Registration,
template.SerialNumber,
template.Manufactured,
manufactured,
template.Model?.Name,
template.Model?.Manufacturer?.Name);
return aircraft;
Expand Down
4 changes: 0 additions & 4 deletions src/FlightRecorder.Api/Controllers/SightingsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
using FlightRecorder.Entities.Db;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;

namespace FlightRecorder.Api.Controllers
Expand Down
8 changes: 4 additions & 4 deletions src/FlightRecorder.Api/FlightRecorder.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ReleaseVersion>1.7.0.0</ReleaseVersion>
<FileVersion>1.7.0.0</FileVersion>
<ProductVersion>1.7.0</ProductVersion>
<Nullable>enable</Nullable>
<ReleaseVersion>1.8.0.0</ReleaseVersion>
<FileVersion>1.8.0.0</FileVersion>
<ProductVersion>1.8.0</ProductVersion>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
23 changes: 11 additions & 12 deletions src/FlightRecorder.Api/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:1923",
"sslPort": 44325
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"FlightRecorder.Api": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:1923",
"sslPort": 44325
}
}
}
2 changes: 0 additions & 2 deletions src/FlightRecorder.Api/Services/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
using FlightRecorder.Entities.Db;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
using System;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;

namespace FlightRecorder.Api.Services
{
Expand Down
10 changes: 9 additions & 1 deletion src/FlightRecorder.Api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@ public void ConfigureServices(IServiceCollection services)
services.AddControllers();

// Configure the flight log DB context and business logic
var connectionString = Configuration.GetConnectionString("FlightRecorderDB");
services.AddScoped<FlightRecorderDbContext>();
services.AddDbContextPool<FlightRecorderDbContext>(options =>
{
options.UseSqlite(Configuration.GetConnectionString("FlightRecorderDB"));
options.UseSqlite(connectionString);
});
services.AddScoped<FlightRecorderFactory>();


Console.WriteLine(Configuration.GetConnectionString("FlightRecorderDB"));

// Read the configuration file
IConfigurationRoot configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
Expand All @@ -70,6 +74,10 @@ public void ConfigureServices(IServiceCollection services)
logger.LogMessage(Severity.Info, new string('=', 80));
logger.LogMessage(Severity.Info, title);

// Log the connection string
var message = $"Database connection string = {connectionString}";
logger.LogMessage(Severity.Info, message);

// Register the logger with the DI framework
services.AddSingleton<IFlightRecorderLogger>(x => logger);

Expand Down
8 changes: 4 additions & 4 deletions src/FlightRecorder.Api/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"ApplicationSettings": {
"Secret": "e2b6e7fe16ef469d9862d43eb76d00e2802ab769b85848048cc9387743ca2cc38c0f4fd8a0de46798f347bedf676bc31",
"TokenLifespanMinutes": 1440,
"SightingsExportPath": "C:\\OneDrive\\Documents\\Aviation\\FlightRecorder\\Data\\Export",
"AirportsExportPath": "C:\\OneDrive\\Documents\\Aviation\\FlightRecorder\\Data\\Export\\Airports",
"ReportsExportPath": "C:\\OneDrive\\Documents\\Aviation\\FlightRecorder\\Data\\Export\\Reports",
"SightingsExportPath": "C:\\MyApps\\FlightRecorder\\Export",
"AirportsExportPath": "C:\\MyApps\\FlightRecorder\\Export\\Airports",
"ReportsExportPath": "C:\\MyApps\\FlightRecorder\\Export\\Reports",
"LogFile": "C:\\MyApps\\FlightRecorder\\FlightRecorder.Manager.log",
"MinimumLogLevel": "Info",
"ApiEndpoints": [
Expand Down Expand Up @@ -40,6 +40,6 @@
},
"AllowedHosts": "*",
"ConnectionStrings": {
"FlightRecorderDB": "Data Source=C:\\OneDrive\\Documents\\Aviation\\FlightRecorder\\Data\\flightrecorder_dev.db"
"FlightRecorderDB": "Data Source=C:\\MyApps\\FlightRecorder\\flightrecorder_dev.db"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<PackageId>FlightRecorder.BusinessLogic</PackageId>
<PackageVersion>1.5.0.0</PackageVersion>
<PackageVersion>1.6.0.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2020, 2021, 2022, 2023</Copyright>
<Owners>Dave Walker</Owners>
Expand All @@ -16,7 +16,7 @@
<PackageProjectUrl>https://github.com/davewalker5/FlightRecorderDb</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>1.5.0.0</ReleaseVersion>
<ReleaseVersion>1.6.0.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
25 changes: 0 additions & 25 deletions src/FlightRecorder.BusinessLogic/FlightRecorder.BusinessLogic.sln

This file was deleted.

4 changes: 2 additions & 2 deletions src/FlightRecorder.Data/FlightRecorder.Data.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<PackageId>FlightRecorder.Data</PackageId>
<PackageVersion>1.5.0.0</PackageVersion>
<PackageVersion>1.6.0.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2020, 2021, 2022, 2023</Copyright>
<Owners>Dave Walker</Owners>
Expand All @@ -16,7 +16,7 @@
<PackageProjectUrl>https://github.com/davewalker5/FlightRecorderDb</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>1.5.0.0</ReleaseVersion>
<ReleaseVersion>1.6.0.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<PackageId>FlightRecorder.DataExchange</PackageId>
<PackageVersion>1.5.0.0</PackageVersion>
<PackageVersion>1.6.0.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2020, 2021, 2022, 2023</Copyright>
<Owners>Dave Walker</Owners>
Expand All @@ -16,7 +16,7 @@
<PackageProjectUrl>https://github.com/davewalker5/FlightRecorderDb</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>1.5.0.0</ReleaseVersion>
<ReleaseVersion>1.6.0.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/FlightRecorder.Entities/FlightRecorder.Entities.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<PackageId>FlightRecorder.Entities</PackageId>
<PackageVersion>1.5.0.0</PackageVersion>
<PackageVersion>1.6.0.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2020, 2021, 2022, 2023</Copyright>
<Owners>Dave Walker</Owners>
Expand All @@ -16,7 +16,7 @@
<PackageProjectUrl>https://github.com/davewalker5/FlightRecorderDb</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>1.5.0.0</ReleaseVersion>
<ReleaseVersion>1.6.0.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
25 changes: 0 additions & 25 deletions src/FlightRecorder.Entities/FlightRecorder.Entities.sln

This file was deleted.

6 changes: 3 additions & 3 deletions src/FlightRecorder.Manager/FlightRecorder.Manager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ReleaseVersion>1.5.0.0</ReleaseVersion>
<FileVersion>1.5.0.0</FileVersion>
<ProductVersion>1.5.0.0</ProductVersion>
<ReleaseVersion>1.6.0.0</ReleaseVersion>
<FileVersion>1.6.0.0</FileVersion>
<ProductVersion>1.6.0.0</ProductVersion>
<Configurations>Release;Debug</Configurations>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
25 changes: 0 additions & 25 deletions src/FlightRecorder.Manager/FlightRecorder.Manager.sln

This file was deleted.

2 changes: 1 addition & 1 deletion src/FlightRecorder.Mvc/Api/FlightRecorderClientBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected async Task<string> SendIndirectAsync(string routeName, string data, Ht
/// <param name="data"></param>
/// <param name="method"></param>
/// <returns></returns>
protected async Task<string> SendDirectAsync(string route, string? data, HttpMethod method)
protected async Task<string> SendDirectAsync(string route, string data, HttpMethod method)
{
string json = null;

Expand Down
2 changes: 1 addition & 1 deletion src/FlightRecorder.Mvc/Controllers/LoginController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public LoginController(AuthenticationClient client)
[HttpGet]
public IActionResult Index()
{
LoginViewModel model = new LoginViewModel();
var model = new LoginViewModel();
return View(model);
}

Expand Down
Loading

0 comments on commit 0c2381c

Please sign in to comment.