From 1c6f3a19fc03e64e6f0f264900b8b0842a76f85a Mon Sep 17 00:00:00 2001 From: Dave Walker Date: Mon, 11 Mar 2024 18:34:31 +0000 Subject: [PATCH] Added the maintainers controller and database migrations --- .../Controllers/MaintainersController.cs | 116 +++++ .../Controllers/OperatorsController.cs | 2 +- .../DroneFlightLog.Api.csproj | 10 +- .../DroneFlightLog.Data.InMemory.csproj | 12 +- .../DroneFlightLog.Data.Sqlite.csproj | 12 +- .../20240311181826_MaintenanceLog.Designer.cs | 396 ++++++++++++++++++ .../20240311181826_MaintenanceLog.cs | 78 ++++ .../DroneFlightLogDbContextModelSnapshot.cs | 88 +++- .../DroneFlightLog.Data.Tests.csproj | 13 +- .../DroneFlightLog.Data.csproj | 8 +- .../Logic/MaintenanceRecordManager.cs | 8 +- .../DroneFlightLog.Importer.csproj | 10 +- .../DroneFlightLog.Manager.csproj | 14 +- src/DroneFlightLog.Manager/appsettings.json | 2 +- .../DroneFlightLog.Mvc.csproj | 10 +- src/DroneFlightLog.Mvc/Startup.cs | 2 +- 16 files changed, 726 insertions(+), 55 deletions(-) create mode 100644 src/DroneFlightLog.Api/Controllers/MaintainersController.cs create mode 100644 src/DroneFlightLog.Data.Sqlite/Migrations/20240311181826_MaintenanceLog.Designer.cs create mode 100644 src/DroneFlightLog.Data.Sqlite/Migrations/20240311181826_MaintenanceLog.cs diff --git a/src/DroneFlightLog.Api/Controllers/MaintainersController.cs b/src/DroneFlightLog.Api/Controllers/MaintainersController.cs new file mode 100644 index 0000000..999d013 --- /dev/null +++ b/src/DroneFlightLog.Api/Controllers/MaintainersController.cs @@ -0,0 +1,116 @@ +using DroneFlightLog.Data.Entities; +using DroneFlightLog.Data.Exceptions; +using DroneFlightLog.Data.Interfaces; +using DroneFlightLog.Data.Sqlite; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Web; + +namespace DroneFlightLog.Api.Controllers +{ + [Authorize] + [ApiController] + [ApiConventionType(typeof(DefaultApiConventions))] + [Route("[controller]")] + public class MaintainersController : Controller + { + private readonly IDroneFlightLogFactory _factory; + + public MaintainersController(IDroneFlightLogFactory factory) + { + _factory = factory; + } + + [HttpGet] + [Route("{id}")] + public async Task> GetMaintainerAsync(int id) + { + Maintainer maintainer; + + try + { + maintainer = await _factory.Maintainers.GetMaintainerAsync(id); + } + catch (MaintainerNotFoundException) + { + return NotFound(); + } + + return maintainer; + } + + [HttpGet] + [Route("")] + public async Task>> GetMaintainersAsync() + { + List maintainers = await _factory.Maintainers.GetMaintainersAsync().ToListAsync(); + + if (!maintainers.Any()) + { + return NoContent(); + } + + return maintainers; + } + + [HttpGet] + [Route("{firstNames}/{surname}")] + public async Task> FindMaintainerAsync(string firstNames, string surname) + { + string decodedFirstNames = HttpUtility.UrlDecode(firstNames); + string decodedSurname = HttpUtility.UrlDecode(surname); + Maintainer maintainer = await _factory.Maintainers.FindMaintainerAsync(decodedFirstNames, decodedSurname); + + if (maintainer == null) + { + return NotFound(); + } + + return maintainer; + } + + [HttpPut] + [Route("")] + public async Task> UpdateMaintainerAsync([FromBody] Maintainer template) + { + Maintainer maintainer; + + try + { + maintainer = await _factory.Maintainers.UpdateMaintainerAsync(template.Id, + template.FirstNames, + template.Surname); + await _factory.Context.SaveChangesAsync(); + } + catch (MaintainerNotFoundException) + { + return NotFound(); + } + + return maintainer; + } + + [HttpPost] + [Route("")] + public async Task> CreateMaintainerAsync([FromBody] Maintainer template) + { + Maintainer maintainer; + + try + { + maintainer = await _factory.Maintainers.AddMaintainerAsync(template.FirstNames, + template.Surname); + await _factory.Context.SaveChangesAsync(); + } + catch (MaintainerExistsException) + { + return BadRequest(); + } + + return maintainer; + } + } +} diff --git a/src/DroneFlightLog.Api/Controllers/OperatorsController.cs b/src/DroneFlightLog.Api/Controllers/OperatorsController.cs index c737364..72d3ba0 100644 --- a/src/DroneFlightLog.Api/Controllers/OperatorsController.cs +++ b/src/DroneFlightLog.Api/Controllers/OperatorsController.cs @@ -34,7 +34,7 @@ public async Task> GetOperatorAsync(int id) { op = await _factory.Operators.GetOperatorAsync(id); } - catch (LocationNotFoundException) + catch (OperatorNotFoundException) { return NotFound(); } diff --git a/src/DroneFlightLog.Api/DroneFlightLog.Api.csproj b/src/DroneFlightLog.Api/DroneFlightLog.Api.csproj index fe946e7..7e76809 100644 --- a/src/DroneFlightLog.Api/DroneFlightLog.Api.csproj +++ b/src/DroneFlightLog.Api/DroneFlightLog.Api.csproj @@ -20,11 +20,11 @@ - - - - - + + + + + diff --git a/src/DroneFlightLog.Data.InMemory/DroneFlightLog.Data.InMemory.csproj b/src/DroneFlightLog.Data.InMemory/DroneFlightLog.Data.InMemory.csproj index 616cd21..e216247 100644 --- a/src/DroneFlightLog.Data.InMemory/DroneFlightLog.Data.InMemory.csproj +++ b/src/DroneFlightLog.Data.InMemory/DroneFlightLog.Data.InMemory.csproj @@ -3,10 +3,10 @@ net8.0 DroneFlightLog.Data.InMemory - 1.1.1.0 + 1.1.2.0 true Dave Walker - Copyright (c) 2020, 2021, 2022, 2023 Dave Walker + Copyright (c) 2020, 2021, 2022, 2023, 2024 Dave Walker Dave Walker NuGet package and framework updates Drone Flight Logging In Memory Database Layer @@ -16,16 +16,16 @@ https://github.com/davewalker5/DroneFlightLogDb MIT false - 1.1.1.0 + 1.1.2.0 - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/DroneFlightLog.Data.Sqlite/DroneFlightLog.Data.Sqlite.csproj b/src/DroneFlightLog.Data.Sqlite/DroneFlightLog.Data.Sqlite.csproj index 95f9643..c17e550 100644 --- a/src/DroneFlightLog.Data.Sqlite/DroneFlightLog.Data.Sqlite.csproj +++ b/src/DroneFlightLog.Data.Sqlite/DroneFlightLog.Data.Sqlite.csproj @@ -3,10 +3,10 @@ net8.0 DroneFlightLog.Data.Sqlite - 1.1.1.0 + 1.1.2.0 true Dave Walker - Copyright (c) 2020, 2021, 2022, 2023 Dave Walker + Copyright (c) 2020, 2021, 2022, 2023, 2024 Dave Walker Dave Walker NuGet package and framework updates Drone Flight Logging SQLite Database Layer @@ -16,19 +16,19 @@ https://github.com/davewalker5/DroneFlightLogDb MIT false - 1.1.1.0 + 1.1.2.0 - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/src/DroneFlightLog.Data.Sqlite/Migrations/20240311181826_MaintenanceLog.Designer.cs b/src/DroneFlightLog.Data.Sqlite/Migrations/20240311181826_MaintenanceLog.Designer.cs new file mode 100644 index 0000000..142df3f --- /dev/null +++ b/src/DroneFlightLog.Data.Sqlite/Migrations/20240311181826_MaintenanceLog.Designer.cs @@ -0,0 +1,396 @@ +// +using System; +using DroneFlightLog.Data.Sqlite; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace DroneFlightLog.Data.Sqlite.Migrations +{ + [DbContext(typeof(DroneFlightLogDbContext))] + [Migration("20240311181826_MaintenanceLog")] + partial class MaintenanceLog + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.2"); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.Address", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Country") + .HasColumnType("TEXT"); + + b.Property("County") + .HasColumnType("TEXT"); + + b.Property("Number") + .HasColumnType("TEXT"); + + b.Property("Postcode") + .HasColumnType("TEXT"); + + b.Property("Street") + .HasColumnType("TEXT"); + + b.Property("Town") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Addresses"); + }); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.Drone", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ModelId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("SerialNumber") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ModelId"); + + b.ToTable("Drones"); + }); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.Flight", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DroneId") + .HasColumnType("INTEGER"); + + b.Property("End") + .HasColumnType("TEXT"); + + b.Property("LocationId") + .HasColumnType("INTEGER"); + + b.Property("OperatorId") + .HasColumnType("INTEGER"); + + b.Property("Start") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("DroneId"); + + b.HasIndex("LocationId"); + + b.HasIndex("OperatorId"); + + b.ToTable("Flights"); + }); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.FlightLogUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Password") + .HasColumnType("TEXT"); + + b.Property("UserName") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("FlightLogUsers"); + }); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.FlightProperty", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DataType") + .HasColumnType("INTEGER"); + + b.Property("IsSingleInstance") + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("FlightProperties"); + }); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.FlightPropertyValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DateValue") + .HasColumnType("TEXT"); + + b.Property("FlightId") + .HasColumnType("INTEGER"); + + b.Property("NumberValue") + .HasColumnType("TEXT"); + + b.Property("PropertyId") + .HasColumnType("INTEGER"); + + b.Property("StringValue") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("FlightId"); + + b.HasIndex("PropertyId"); + + b.ToTable("FlightPropertyValues"); + }); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Locations"); + }); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.Maintainer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("FirstNames") + .HasColumnType("TEXT"); + + b.Property("Surname") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Maintainers"); + }); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.MaintenanceRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DateCompleted") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("DroneId") + .HasColumnType("INTEGER"); + + b.Property("MaintainerId") + .HasColumnType("INTEGER"); + + b.Property("Notes") + .HasColumnType("TEXT"); + + b.Property("RecordType") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("MaintainerId"); + + b.ToTable("MaintenanceRecords"); + }); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.Manufacturer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Manufacturers"); + }); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.Model", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ManufacturerId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ManufacturerId"); + + b.ToTable("Models"); + }); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.Operator", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AddressId") + .HasColumnType("INTEGER"); + + b.Property("DoB") + .HasColumnType("TEXT"); + + b.Property("FirstNames") + .HasColumnType("TEXT"); + + b.Property("FlyerNumber") + .HasColumnType("TEXT"); + + b.Property("OperatorNumber") + .HasColumnType("TEXT"); + + b.Property("Surname") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("AddressId"); + + b.ToTable("Operators"); + }); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.Drone", b => + { + b.HasOne("DroneFlightLog.Data.Entities.Model", "Model") + .WithMany() + .HasForeignKey("ModelId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Model"); + }); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.Flight", b => + { + b.HasOne("DroneFlightLog.Data.Entities.Drone", "Drone") + .WithMany() + .HasForeignKey("DroneId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DroneFlightLog.Data.Entities.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DroneFlightLog.Data.Entities.Operator", "Operator") + .WithMany() + .HasForeignKey("OperatorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Drone"); + + b.Navigation("Location"); + + b.Navigation("Operator"); + }); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.FlightPropertyValue", b => + { + b.HasOne("DroneFlightLog.Data.Entities.Flight", "Flight") + .WithMany("Properties") + .HasForeignKey("FlightId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DroneFlightLog.Data.Entities.FlightProperty", "Property") + .WithMany() + .HasForeignKey("PropertyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Flight"); + + b.Navigation("Property"); + }); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.MaintenanceRecord", b => + { + b.HasOne("DroneFlightLog.Data.Entities.Maintainer", "Maintainer") + .WithMany() + .HasForeignKey("MaintainerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Maintainer"); + }); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.Model", b => + { + b.HasOne("DroneFlightLog.Data.Entities.Manufacturer", "Manufacturer") + .WithMany() + .HasForeignKey("ManufacturerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacturer"); + }); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.Operator", b => + { + b.HasOne("DroneFlightLog.Data.Entities.Address", "Address") + .WithMany() + .HasForeignKey("AddressId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Address"); + }); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.Flight", b => + { + b.Navigation("Properties"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/DroneFlightLog.Data.Sqlite/Migrations/20240311181826_MaintenanceLog.cs b/src/DroneFlightLog.Data.Sqlite/Migrations/20240311181826_MaintenanceLog.cs new file mode 100644 index 0000000..b54b103 --- /dev/null +++ b/src/DroneFlightLog.Data.Sqlite/Migrations/20240311181826_MaintenanceLog.cs @@ -0,0 +1,78 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DroneFlightLog.Data.Sqlite.Migrations +{ + /// + public partial class MaintenanceLog : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Token", + table: "FlightLogUsers"); + + migrationBuilder.CreateTable( + name: "Maintainers", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + FirstNames = table.Column(type: "TEXT", nullable: true), + Surname = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Maintainers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "MaintenanceRecords", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + MaintainerId = table.Column(type: "INTEGER", nullable: false), + DroneId = table.Column(type: "INTEGER", nullable: false), + DateCompleted = table.Column(type: "TEXT", nullable: false), + RecordType = table.Column(type: "INTEGER", nullable: false), + Description = table.Column(type: "TEXT", nullable: true), + Notes = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_MaintenanceRecords", x => x.Id); + table.ForeignKey( + name: "FK_MaintenanceRecords_Maintainers_MaintainerId", + column: x => x.MaintainerId, + principalTable: "Maintainers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_MaintenanceRecords_MaintainerId", + table: "MaintenanceRecords", + column: "MaintainerId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "MaintenanceRecords"); + + migrationBuilder.DropTable( + name: "Maintainers"); + + migrationBuilder.AddColumn( + name: "Token", + table: "FlightLogUsers", + type: "TEXT", + nullable: true); + } + } +} diff --git a/src/DroneFlightLog.Data.Sqlite/Migrations/DroneFlightLogDbContextModelSnapshot.cs b/src/DroneFlightLog.Data.Sqlite/Migrations/DroneFlightLogDbContextModelSnapshot.cs index 2e4730e..7d16791 100644 --- a/src/DroneFlightLog.Data.Sqlite/Migrations/DroneFlightLogDbContextModelSnapshot.cs +++ b/src/DroneFlightLog.Data.Sqlite/Migrations/DroneFlightLogDbContextModelSnapshot.cs @@ -5,6 +5,8 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +#nullable disable + namespace DroneFlightLog.Data.Sqlite.Migrations { [DbContext(typeof(DroneFlightLogDbContext))] @@ -13,8 +15,7 @@ partial class DroneFlightLogDbContextModelSnapshot : ModelSnapshot protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "3.1.1"); + modelBuilder.HasAnnotation("ProductVersion", "8.0.2"); modelBuilder.Entity("DroneFlightLog.Data.Entities.Address", b => { @@ -108,9 +109,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Password") .HasColumnType("TEXT"); - b.Property("Token") - .HasColumnType("TEXT"); - b.Property("UserName") .HasColumnType("TEXT"); @@ -183,6 +181,54 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Locations"); }); + modelBuilder.Entity("DroneFlightLog.Data.Entities.Maintainer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("FirstNames") + .HasColumnType("TEXT"); + + b.Property("Surname") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Maintainers"); + }); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.MaintenanceRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DateCompleted") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("DroneId") + .HasColumnType("INTEGER"); + + b.Property("MaintainerId") + .HasColumnType("INTEGER"); + + b.Property("Notes") + .HasColumnType("TEXT"); + + b.Property("RecordType") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("MaintainerId"); + + b.ToTable("MaintenanceRecords"); + }); + modelBuilder.Entity("DroneFlightLog.Data.Entities.Manufacturer", b => { b.Property("Id") @@ -254,6 +300,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasForeignKey("ModelId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Model"); }); modelBuilder.Entity("DroneFlightLog.Data.Entities.Flight", b => @@ -275,6 +323,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasForeignKey("OperatorId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Drone"); + + b.Navigation("Location"); + + b.Navigation("Operator"); }); modelBuilder.Entity("DroneFlightLog.Data.Entities.FlightPropertyValue", b => @@ -290,6 +344,21 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasForeignKey("PropertyId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Flight"); + + b.Navigation("Property"); + }); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.MaintenanceRecord", b => + { + b.HasOne("DroneFlightLog.Data.Entities.Maintainer", "Maintainer") + .WithMany() + .HasForeignKey("MaintainerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Maintainer"); }); modelBuilder.Entity("DroneFlightLog.Data.Entities.Model", b => @@ -299,6 +368,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasForeignKey("ManufacturerId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Manufacturer"); }); modelBuilder.Entity("DroneFlightLog.Data.Entities.Operator", b => @@ -308,6 +379,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasForeignKey("AddressId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Address"); + }); + + modelBuilder.Entity("DroneFlightLog.Data.Entities.Flight", b => + { + b.Navigation("Properties"); }); #pragma warning restore 612, 618 } diff --git a/src/DroneFlightLog.Data.Tests/DroneFlightLog.Data.Tests.csproj b/src/DroneFlightLog.Data.Tests/DroneFlightLog.Data.Tests.csproj index 9720e43..20dabcd 100644 --- a/src/DroneFlightLog.Data.Tests/DroneFlightLog.Data.Tests.csproj +++ b/src/DroneFlightLog.Data.Tests/DroneFlightLog.Data.Tests.csproj @@ -10,15 +10,14 @@ - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/DroneFlightLog.Data/DroneFlightLog.Data.csproj b/src/DroneFlightLog.Data/DroneFlightLog.Data.csproj index a8b28b0..7d6b14c 100644 --- a/src/DroneFlightLog.Data/DroneFlightLog.Data.csproj +++ b/src/DroneFlightLog.Data/DroneFlightLog.Data.csproj @@ -3,10 +3,10 @@ net8.0 DroneFlightLog.Data - 1.1.1.0 + 1.1.2.0 true Dave Walker - Copyright (c) 2020, 2021, 2022, 2023 Dave Walker + Copyright (c) 2020, 2021, 2022, 2023, 2024 Dave Walker Dave Walker NuGet package and framework updates Drone Flight Logging Database Layer @@ -16,11 +16,11 @@ https://github.com/davewalker5/DroneFlightLogDb MIT false - 1.1.1.0 + 1.1.2.0 - + diff --git a/src/DroneFlightLog.Data/Logic/MaintenanceRecordManager.cs b/src/DroneFlightLog.Data/Logic/MaintenanceRecordManager.cs index d5df736..5cd2238 100644 --- a/src/DroneFlightLog.Data/Logic/MaintenanceRecordManager.cs +++ b/src/DroneFlightLog.Data/Logic/MaintenanceRecordManager.cs @@ -29,7 +29,7 @@ internal MaintenanceRecordManager(IDroneFlightLogFactory factory) /// /// /// - public MaintenanceRecord AddMaintenanceRecord(int maintainerId, int droneId, MaintenanceRecordType type, DateTime completed, string description, string? notes) + public MaintenanceRecord AddMaintenanceRecord(int maintainerId, int droneId, MaintenanceRecordType type, DateTime completed, string description, string notes) { // These will throw exceptions if the corresponding entities do not exist _factory.Maintainers.GetMaintainer(maintainerId); @@ -59,7 +59,7 @@ public MaintenanceRecord AddMaintenanceRecord(int maintainerId, int droneId, Mai /// /// /// - public async Task AddMaintenanceRecordAsync(int maintainerId, int droneId, MaintenanceRecordType type, DateTime completed, string description, string? notes) + public async Task AddMaintenanceRecordAsync(int maintainerId, int droneId, MaintenanceRecordType type, DateTime completed, string description, string notes) { // These will throw exceptions if the corresponding entities do not exist await _factory.Maintainers.GetMaintainerAsync(maintainerId); @@ -114,7 +114,7 @@ public async Task GetMaintenanceRecordAsync(int id) /// /// /// - public MaintenanceRecord UpdateMaintenanceRecord(int id, int maintainerId, int droneId, MaintenanceRecordType type, DateTime completed, string description, string? notes) + public MaintenanceRecord UpdateMaintenanceRecord(int id, int maintainerId, int droneId, MaintenanceRecordType type, DateTime completed, string description, string notes) { // These will throw exceptions if the corresponding entities do not exist _factory.Maintainers.GetMaintainer(maintainerId); @@ -142,7 +142,7 @@ public MaintenanceRecord UpdateMaintenanceRecord(int id, int maintainerId, int d /// /// /// - public async Task UpdateMaintenanceRecordAsync(int id, int maintainerId, int droneId, MaintenanceRecordType type, DateTime completed, string description, string? notes) + public async Task UpdateMaintenanceRecordAsync(int id, int maintainerId, int droneId, MaintenanceRecordType type, DateTime completed, string description, string notes) { // These will throw exceptions if the corresponding entities do not exist await _factory.Maintainers.GetMaintainerAsync(maintainerId); diff --git a/src/DroneFlightLog.Importer/DroneFlightLog.Importer.csproj b/src/DroneFlightLog.Importer/DroneFlightLog.Importer.csproj index ba6b06f..5222c76 100644 --- a/src/DroneFlightLog.Importer/DroneFlightLog.Importer.csproj +++ b/src/DroneFlightLog.Importer/DroneFlightLog.Importer.csproj @@ -3,9 +3,9 @@ Exe net8.0 - 1.1.1.0 - 1.1.1.0 - 1.1.1.0 + 1.1.2.0 + 1.1.2.0 + 1.1.2.0 Release;Debug enable false @@ -24,8 +24,8 @@ - - + + diff --git a/src/DroneFlightLog.Manager/DroneFlightLog.Manager.csproj b/src/DroneFlightLog.Manager/DroneFlightLog.Manager.csproj index 98e3c3a..d34e87d 100644 --- a/src/DroneFlightLog.Manager/DroneFlightLog.Manager.csproj +++ b/src/DroneFlightLog.Manager/DroneFlightLog.Manager.csproj @@ -1,11 +1,11 @@ - + Exe net8.0 - 1.1.1.0 - 1.1.1.0 - 1.1.1 + 1.1.2.0 + 1.1.2.0 + 1.1.2 enable false @@ -19,7 +19,11 @@ - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/DroneFlightLog.Manager/appsettings.json b/src/DroneFlightLog.Manager/appsettings.json index 2c1c79d..3f3f214 100644 --- a/src/DroneFlightLog.Manager/appsettings.json +++ b/src/DroneFlightLog.Manager/appsettings.json @@ -1,5 +1,5 @@ { "ConnectionStrings": { - "DroneLogDb": "Data Source=droneflightlog.db" + "DroneLogDb": "Data Source=C:\\MyApps\\DroneFlightLog\\droneflightlog_dev.db" } } diff --git a/src/DroneFlightLog.Mvc/DroneFlightLog.Mvc.csproj b/src/DroneFlightLog.Mvc/DroneFlightLog.Mvc.csproj index 67164db..73c42df 100644 --- a/src/DroneFlightLog.Mvc/DroneFlightLog.Mvc.csproj +++ b/src/DroneFlightLog.Mvc/DroneFlightLog.Mvc.csproj @@ -2,9 +2,9 @@ net8.0 - 1.1.4.0 - 1.1.4.0 - 1.1.4.0 + 1.1.5.0 + 1.1.5.0 + 1.1.5.0 Release;Debug false @@ -38,8 +38,8 @@ - - + + diff --git a/src/DroneFlightLog.Mvc/Startup.cs b/src/DroneFlightLog.Mvc/Startup.cs index 2cb915a..68114df 100644 --- a/src/DroneFlightLog.Mvc/Startup.cs +++ b/src/DroneFlightLog.Mvc/Startup.cs @@ -117,7 +117,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) string token = context.Session.GetString(LoginController.TokenSessionKey); if (!string.IsNullOrEmpty(token)) { - context.Request.Headers.Add("Authorization", "Bearer " + token); + context.Request.Headers.Append("Authorization", "Bearer " + token); } await next(); });