Skip to content

Commit

Permalink
Merge pull request #14 from davewalker5/optional_aircraft_properties
Browse files Browse the repository at this point in the history
Make serial number and year of manufacture optional aircraft properties
  • Loading branch information
davewalker5 committed Jul 29, 2023
2 parents e15360e + 8dfc34a commit ee295dc
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 23 deletions.
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.0.4.0</PackageVersion>
<PackageVersion>1.0.5.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2020, 2021, 2022</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.0.4.0</ReleaseVersion>
<ReleaseVersion>1.0.5.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/FlightRecorder.BusinessLogic/Logic/AircraftManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public async Task<IAsyncEnumerable<Aircraft>> ListByManufacturerAsync(string man
/// <param name="model"></param>
/// <param name="manufacturer"></param>
/// <returns></returns>
public Aircraft Add(string registration, string serialNumber, long yearOfManufacture, string modelName, string manufacturerName)
public Aircraft Add(string registration, string serialNumber, long? yearOfManufacture, string modelName, string manufacturerName)
{
registration = registration.CleanString().ToUpper();
Aircraft aircraft = Get(a => a.Registration == registration);
Expand Down Expand Up @@ -254,7 +254,7 @@ public Aircraft Add(string registration, string serialNumber, long yearOfManufac
/// <param name="model"></param>
/// <param name="manufacturer"></param>
/// <returns></returns>
public async Task<Aircraft> AddAsync(string registration, string serialNumber, long yearOfManufacture, string modelName, string manufacturerName)
public async Task<Aircraft> AddAsync(string registration, string serialNumber, long? yearOfManufacture, string modelName, string manufacturerName)
{
registration = registration.CleanString().ToUpper();
Aircraft aircraft = await GetAsync(a => a.Registration == registration);
Expand Down
4 changes: 2 additions & 2 deletions src/FlightRecorder.BusinessLogic/Logic/SightingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public async Task<Sighting> AddAsync(long altitude, DateTime date, long location
/// <returns></returns>
public Sighting Add(FlattenedSighting flattened)
{
long yearOfManufacture = DateTime.Now.Year - flattened.Age;
long? yearOfManufacture = !string.IsNullOrEmpty(flattened.Age) ? DateTime.Now.Year - long.Parse(flattened.Age) : null;
long aircraftId = _factory.Aircraft.Add(flattened.Registration, flattened.SerialNumber, yearOfManufacture, flattened.Model, flattened.Manufacturer).Id;
long flightId = _factory.Flights.Add(flattened.FlightNumber, flattened.Embarkation, flattened.Destination, flattened.Airline).Id;
long locationId = _factory.Locations.Add(flattened.Location).Id;
Expand All @@ -214,7 +214,7 @@ public Sighting Add(FlattenedSighting flattened)
/// <returns></returns>
public async Task<Sighting> AddAsync(FlattenedSighting flattened)
{
long yearOfManufacture = DateTime.Now.Year - flattened.Age;
long? yearOfManufacture = !string.IsNullOrEmpty(flattened.Age) ? DateTime.Now.Year - long.Parse(flattened.Age) : null;
long aircraftId = (await _factory.Aircraft.AddAsync(flattened.Registration, flattened.SerialNumber, yearOfManufacture, flattened.Model, flattened.Manufacturer)).Id;
long flightId = (await _factory.Flights.AddAsync(flattened.FlightNumber, flattened.Embarkation, flattened.Destination, flattened.Airline)).Id;
long locationId = (await _factory.Locations.AddAsync(flattened.Location)).Id;
Expand Down
6 changes: 3 additions & 3 deletions src/FlightRecorder.Data/FlightRecorder.Data.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<PackageId>FlightRecorder.Data</PackageId>
<PackageVersion>1.0.4.0</PackageVersion>
<PackageVersion>1.0.5.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2020, 2021, 2022</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.0.4.0</ReleaseVersion>
<ReleaseVersion>1.0.5.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.0.4.0</PackageVersion>
<PackageVersion>1.0.5.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2020, 2021, 2022</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.0.4.0</ReleaseVersion>
<ReleaseVersion>1.0.5.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/FlightRecorder.Entities/DataExchange/FlattenedSighting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class FlattenedSighting
public string SerialNumber { get; set; }
public string Manufacturer { get; set; }
public string Model { get; set; }
public long Age { get; set; }
public string Age { get; set; }
public string Embarkation { get; set; }
public string Destination { get; set; }
public long Altitude { get; set; }
Expand All @@ -39,7 +39,7 @@ public static FlattenedSighting FromCsv(string record)
SerialNumber = words[3],
Manufacturer = words[4],
Model = words[5],
Age = long.Parse(words[6]),
Age = words[6],
Embarkation = words[7],
Destination = words[8],
Altitude = long.Parse(words[9]),
Expand Down
2 changes: 1 addition & 1 deletion src/FlightRecorder.Entities/Db/Aircraft.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public partial class Aircraft
public long ModelId { get; set; }
public string Registration { get; set; }
public string SerialNumber { get; set; }
public long Manufactured { get; set; }
public long? Manufactured { get; set; }

public virtual Model Model { get; set; }
}
Expand Down
12 changes: 12 additions & 0 deletions src/FlightRecorder.Entities/Db/JobStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FlightRecorder.Entities.Db
{
internal class JobStatus

Check warning on line 9 in src/FlightRecorder.Entities/Db/JobStatus.cs

View workflow job for this annotation

GitHub Actions / build

Remove this empty class, write its code or make it an "interface".

Check warning on line 9 in src/FlightRecorder.Entities/Db/JobStatus.cs

View workflow job for this annotation

GitHub Actions / build

Remove this empty class, write its code or make it an "interface".

Check warning on line 9 in src/FlightRecorder.Entities/Db/JobStatus.cs

View workflow job for this annotation

GitHub Actions / build

Remove this empty class, write its code or make it an "interface".

Check warning on line 9 in src/FlightRecorder.Entities/Db/JobStatus.cs

View workflow job for this annotation

GitHub Actions / build

Remove this empty class, write its code or make it an "interface".
{
}
}
2 changes: 1 addition & 1 deletion src/FlightRecorder.Entities/Db/Sighting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public FlattenedSighting Flatten()
SerialNumber = Aircraft.SerialNumber,
Manufacturer = Aircraft.Model.Manufacturer.Name,
Model = Aircraft.Model.Name,
Age = DateTime.Now.Year - Aircraft.Manufactured,
Age = (Aircraft.Manufactured != null) ? (DateTime.Now.Year - Aircraft.Manufactured).ToString() : "",
Embarkation = Flight.Embarkation,
Destination = Flight.Destination,
Altitude = Altitude,
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.0.4.0</PackageVersion>
<PackageVersion>1.0.5.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2020, 2021, 2022</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.0.4.0</ReleaseVersion>
<ReleaseVersion>1.0.5.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/FlightRecorder.Entities/Interfaces/IAircraftManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace FlightRecorder.Entities.Interfaces
{
public interface IAircraftManager
{
Aircraft Add(string registration, string serialNumber, long yearOfManufacture, string modelName, string manufacturerName);
Task<Aircraft> AddAsync(string registration, string serialNumber, long yearOfManufacture, string modelName, string manufacturerName);
Aircraft Add(string registration, string serialNumber, long? yearOfManufacture, string modelName, string manufacturerName);
Task<Aircraft> AddAsync(string registration, string serialNumber, long? yearOfManufacture, string modelName, string manufacturerName);
Aircraft Get(Expression<Func<Aircraft, bool>> predicate = null);
Task<Aircraft> GetAsync(Expression<Func<Aircraft, bool>> predicate);
IEnumerable<Aircraft> List(Expression<Func<Aircraft, bool>> predicate, int pageNumber, int pageSize);
Expand Down
2 changes: 1 addition & 1 deletion src/FlightRecorder.Manager/FlightRecorder.Manager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ReleaseVersion>1.0.4.0</ReleaseVersion>
<ReleaseVersion>1.0.5.0</ReleaseVersion>
<Configurations>Release;Debug</Configurations>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/FlightRecorder.Tests/DataExchangeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class DataExchangeTests
private const string ManufacturerName = "Airbus";
private const string Registration = "G-EZFY";
private const string SerialNumber = "4418";
private const long Age = 9;
private const string Age = "9";

private const long Altitude = 930;
private readonly DateTime SightingDate = new DateTime(2019, 9, 22);
Expand Down Expand Up @@ -77,7 +77,7 @@ public void AddAndGetTest()
Assert.IsNotNull(sighting.Aircraft);
Assert.AreEqual(Registration, sighting.Aircraft.Registration);
Assert.AreEqual(SerialNumber, sighting.Aircraft.SerialNumber);
Assert.AreEqual(DateTime.Now.Year - Age, sighting.Aircraft.Manufactured);
Assert.AreEqual(DateTime.Now.Year - long.Parse(Age), sighting.Aircraft.Manufactured);

Assert.IsNotNull(sighting.Aircraft.Model);
Assert.AreEqual(ModelName, sighting.Aircraft.Model.Name);
Expand Down
2 changes: 1 addition & 1 deletion src/FlightRecorder.Tests/FlightRecorder.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net7.0</TargetFramework>

<IsPackable>false</IsPackable>
<ReleaseVersion>1.0.4.0</ReleaseVersion>
<ReleaseVersion>1.0.5.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit ee295dc

Please sign in to comment.