Little test with AI + Add the equipment #8

Merged
sandre merged 29 commits from feature/by-ai into master 2026-05-16 09:24:15 +00:00
7 changed files with 251 additions and 18 deletions
Showing only changes of commit b03085acbe - Show all commits
@@ -1,4 +1,4 @@
using LiteDB; using LiteDB;
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories; using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces; using skydiveLogs_api.Infrastructure.Interfaces;
@@ -11,6 +11,10 @@ namespace skydiveLogs_api.Infrastructure
{ {
#region Public Constructors #region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="AircraftRepository"/> class
/// </summary>
/// <param name="dataProvider">The data provider to use for data access</param>
public AircraftRepository(IDataProvider dataProvider) public AircraftRepository(IDataProvider dataProvider)
{ {
_dataProvider = dataProvider; _dataProvider = dataProvider;
@@ -21,6 +25,11 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods #region Public Methods
/// <summary>
/// Adds a new aircraft to the database
/// </summary>
/// <param name="newAircraft">The aircraft instance to add</param>
/// <returns>The number of rows affected (0 if insert failed)</returns>
public int Add(Aircraft newAircraft) public int Add(Aircraft newAircraft)
{ {
int result; int result;
@@ -38,21 +47,39 @@ namespace skydiveLogs_api.Infrastructure
return result; return result;
} }
/// <summary>
/// Retrieves all aircraft from the database
/// </summary>
/// <returns>A collection of all aircraft instances</returns>
public IEnumerable<Aircraft> GetAll() public IEnumerable<Aircraft> GetAll()
{ {
return _col.FindAll().ToList(); return _col.FindAll().ToList();
} }
/// <summary>
/// Retrieves an aircraft by its unique identifier
/// </summary>
/// <param name="id">The unique identifier of the aircraft</param>
/// <returns>The aircraft instance or null if not found</returns>
public Aircraft GetById(int id) public Aircraft GetById(int id)
{ {
return _col.FindById(new BsonValue(id)); return _col.FindById(new BsonValue(id));
} }
/// <summary>
/// Gets the total count of aircraft in the database
/// </summary>
/// <returns>The total number of aircraft</returns>
public int GetCount() public int GetCount()
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
/// <summary>
/// Updates an existing aircraft in the database
/// </summary>
/// <param name="aircraft">The aircraft instance to update</param>
/// <returns>True if the update was successful, false otherwise</returns>
public bool Update(Aircraft aircraft) public bool Update(Aircraft aircraft)
{ {
return _col.Update(aircraft); return _col.Update(aircraft);
@@ -67,4 +94,4 @@ namespace skydiveLogs_api.Infrastructure
#endregion Private Fields #endregion Private Fields
} }
} }
@@ -1,4 +1,4 @@
using LiteDB; using LiteDB;
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories; using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces; using skydiveLogs_api.Infrastructure.Interfaces;
@@ -11,6 +11,10 @@ namespace skydiveLogs_api.Infrastructure
{ {
#region Public Constructors #region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="DropZoneRepository"/> class
/// </summary>
/// <param name="dataProvider">The data provider to use for data access</param>
public DropZoneRepository(IDataProvider dataProvider) public DropZoneRepository(IDataProvider dataProvider)
{ {
_dataProvider = dataProvider; _dataProvider = dataProvider;
@@ -21,13 +25,18 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods #region Public Methods
public int Add(DropZone newDz) /// <summary>
/// Adds a new drop zone to the database
/// </summary>
/// <param name="newDropZone">The drop zone instance to add</param>
/// <returns>The number of rows affected (0 if insert failed)</returns>
public int Add(DropZone newDropZone)
{ {
int result; int result;
try try
{ {
var tmp = _col.Insert(newDz); var tmp = _col.Insert(newDropZone);
result = tmp.AsInt32; result = tmp.AsInt32;
} }
catch catch
@@ -38,24 +47,42 @@ namespace skydiveLogs_api.Infrastructure
return result; return result;
} }
/// <summary>
/// Retrieves all drop zones from the database
/// </summary>
/// <returns>A collection of all drop zone instances</returns>
public IEnumerable<DropZone> GetAll() public IEnumerable<DropZone> GetAll()
{ {
return _col.FindAll().ToList(); return _col.FindAll().ToList();
} }
/// <summary>
/// Retrieves a drop zone by its unique identifier
/// </summary>
/// <param name="id">The unique identifier of the drop zone</param>
/// <returns>The drop zone instance or null if not found</returns>
public DropZone GetById(int id) public DropZone GetById(int id)
{ {
return _col.FindById(new BsonValue(id)); return _col.FindById(new BsonValue(id));
} }
/// <summary>
/// Gets the total count of drop zones in the database
/// </summary>
/// <returns>The total number of drop zones</returns>
public int GetCount() public int GetCount()
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
public bool Update(DropZone updatedDz) /// <summary>
/// Updates an existing drop zone in the database
/// </summary>
/// <param name="dropZone">The drop zone instance to update</param>
/// <returns>True if the update was successful, false otherwise</returns>
public bool Update(DropZone dropZone)
{ {
return _col.Update(updatedDz); return _col.Update(dropZone);
} }
#endregion Public Methods #endregion Public Methods
@@ -67,4 +94,4 @@ namespace skydiveLogs_api.Infrastructure
#endregion Private Fields #endregion Private Fields
} }
} }
@@ -1,4 +1,4 @@
using LiteDB; using LiteDB;
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories; using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces; using skydiveLogs_api.Infrastructure.Interfaces;
@@ -10,6 +10,10 @@ namespace skydiveLogs_api.Infrastructure
{ {
#region Public Constructors #region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="FavoriteDropZoneRepository"/> class
/// </summary>
/// <param name="dataProvider">The data provider to use for data access</param>
public FavoriteDropZoneRepository(IDataProvider dataProvider) public FavoriteDropZoneRepository(IDataProvider dataProvider)
{ {
_dataProvider = dataProvider; _dataProvider = dataProvider;
@@ -20,6 +24,11 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods #region Public Methods
/// <summary>
/// Adds a new favorite drop zone to the database
/// </summary>
/// <param name="favoriteToAdd">The favorite drop zone instance to add</param>
/// <returns>The number of rows affected (0 if insert failed)</returns>
public int Add(FavoriteDropZone favoriteToAdd) public int Add(FavoriteDropZone favoriteToAdd)
{ {
int result; int result;
@@ -37,11 +46,22 @@ namespace skydiveLogs_api.Infrastructure
return result; return result;
} }
/// <summary>
/// Deletes a favorite drop zone by drop zone ID and user ID
/// </summary>
/// <param name="dropZoneId">The unique identifier of the drop zone</param>
/// <param name="userId">The unique identifier of the user</param>
/// <returns>The number of rows affected (0 if delete failed)</returns>
public int Delete(int dropZoneId, int userId) public int Delete(int dropZoneId, int userId)
{ {
return _col.DeleteMany(d => d.DropZone.Id == dropZoneId && d.User.Id == userId); return _col.DeleteMany(d => d.DropZone.Id == dropZoneId && d.User.Id == userId);
} }
/// <summary>
/// Retrieves all favorite drop zones for a specific user
/// </summary>
/// <param name="user">The user whose favorite drop zones to retrieve</param>
/// <returns>A collection of favorite drop zone instances belonging to the user</returns>
public IEnumerable<FavoriteDropZone> GetAll(User user) public IEnumerable<FavoriteDropZone> GetAll(User user)
{ {
return _col.Query() return _col.Query()
@@ -49,21 +69,39 @@ namespace skydiveLogs_api.Infrastructure
.ToList(); .ToList();
} }
/// <summary>
/// Retrieves all favorite drop zones from the database
/// </summary>
/// <returns>A collection of all favorite drop zone instances</returns>
public IEnumerable<FavoriteDropZone> GetAll() public IEnumerable<FavoriteDropZone> GetAll()
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
/// <summary>
/// Retrieves a favorite drop zone by its unique identifier
/// </summary>
/// <param name="id">The unique identifier of the favorite drop zone</param>
/// <returns>The favorite drop zone instance or null if not found</returns>
public FavoriteDropZone GetById(int id) public FavoriteDropZone GetById(int id)
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
/// <summary>
/// Gets the total count of favorite drop zones in the database
/// </summary>
/// <returns>The total number of favorite drop zones</returns>
public int GetCount() public int GetCount()
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
/// <summary>
/// Updates an existing favorite drop zone in the database
/// </summary>
/// <param name="updated">The favorite drop zone instance to update</param>
/// <returns>True if the update was successful, false otherwise</returns>
public bool Update(FavoriteDropZone updated) public bool Update(FavoriteDropZone updated)
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
@@ -78,4 +116,4 @@ namespace skydiveLogs_api.Infrastructure
#endregion Private Fields #endregion Private Fields
} }
} }
@@ -1,4 +1,4 @@
using LiteDB; using LiteDB;
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories; using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces; using skydiveLogs_api.Infrastructure.Interfaces;
@@ -10,6 +10,10 @@ namespace skydiveLogs_api.Infrastructure
{ {
#region Public Constructors #region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="GearRepository"/> class
/// </summary>
/// <param name="dataProvider">The data provider to use for data access</param>
public GearRepository(IDataProvider dataProvider) public GearRepository(IDataProvider dataProvider)
{ {
_dataProvider = dataProvider; _dataProvider = dataProvider;
@@ -20,6 +24,11 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods #region Public Methods
/// <summary>
/// Adds a new gear item to the database
/// </summary>
/// <param name="newGear">The gear instance to add</param>
/// <returns>The number of rows affected (0 if insert failed)</returns>
public int Add(Gear newGear) public int Add(Gear newGear)
{ {
int result; int result;
@@ -37,11 +46,20 @@ namespace skydiveLogs_api.Infrastructure
return result; return result;
} }
/// <summary>
/// Retrieves all gear items from the database
/// </summary>
/// <returns>A collection of all gear instances</returns>
public IEnumerable<Gear> GetAll() public IEnumerable<Gear> GetAll()
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
/// <summary>
/// Retrieves all gear items for a specific user
/// </summary>
/// <param name="user">The user whose gear items to retrieve</param>
/// <returns>A collection of gear instances belonging to the user</returns>
public IEnumerable<Gear> GetAll(User user) public IEnumerable<Gear> GetAll(User user)
{ {
return _col.Include(x => x.User) return _col.Include(x => x.User)
@@ -50,16 +68,30 @@ namespace skydiveLogs_api.Infrastructure
.ToList(); .ToList();
} }
/// <summary>
/// Retrieves a gear item by its unique identifier
/// </summary>
/// <param name="id">The unique identifier of the gear</param>
/// <returns>The gear instance or null if not found</returns>
public Gear GetById(int id) public Gear GetById(int id)
{ {
return _col.FindById(new BsonValue(id)); return _col.FindById(new BsonValue(id));
} }
/// <summary>
/// Gets the total count of gear items in the database
/// </summary>
/// <returns>The total number of gear items</returns>
public int GetCount() public int GetCount()
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
/// <summary>
/// Updates an existing gear item in the database
/// </summary>
/// <param name="updatedGear">The gear instance to update</param>
/// <returns>True if the update was successful, false otherwise</returns>
public bool Update(Gear updatedGear) public bool Update(Gear updatedGear)
{ {
return _col.Update(updatedGear); return _col.Update(updatedGear);
@@ -74,4 +106,4 @@ namespace skydiveLogs_api.Infrastructure
#endregion Private Fields #endregion Private Fields
} }
} }
@@ -1,4 +1,4 @@
using LiteDB; using LiteDB;
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories; using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces; using skydiveLogs_api.Infrastructure.Interfaces;
@@ -10,6 +10,10 @@ namespace skydiveLogs_api.Infrastructure
{ {
#region Public Constructors #region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="JumpRepository"/> class
/// </summary>
/// <param name="dataProvider">The data provider to use for data access</param>
public JumpRepository(IDataProvider dataProvider) public JumpRepository(IDataProvider dataProvider)
{ {
_dataProvider = dataProvider; _dataProvider = dataProvider;
@@ -20,6 +24,11 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods #region Public Methods
/// <summary>
/// Adds a new jump to the database
/// </summary>
/// <param name="newJump">The jump instance to add</param>
/// <returns>The number of rows affected (0 if insert failed)</returns>
public int Add(Jump newJump) public int Add(Jump newJump)
{ {
int result; int result;
@@ -37,11 +46,21 @@ namespace skydiveLogs_api.Infrastructure
return result; return result;
} }
/// <summary>
/// Deletes a jump by its unique identifier
/// </summary>
/// <param name="id">The unique identifier of the jump to delete</param>
/// <returns>True if the deletion was successful, false otherwise</returns>
public bool DeleteById(int id) public bool DeleteById(int id)
{ {
return _col.Delete(new BsonValue(id)); return _col.Delete(new BsonValue(id));
} }
/// <summary>
/// Retrieves all jumps for a specific user
/// </summary>
/// <param name="user">The user whose jumps to retrieve</param>
/// <returns>A collection of jump instances belonging to the user</returns>
public IEnumerable<Jump> GetAll(User user) public IEnumerable<Jump> GetAll(User user)
{ {
return _col.Include(x => x.Aircraft) return _col.Include(x => x.Aircraft)
@@ -51,11 +70,22 @@ namespace skydiveLogs_api.Infrastructure
.Find(j => j.User.Id == user.Id); .Find(j => j.User.Id == user.Id);
} }
/// <summary>
/// Retrieves all jumps from the database
/// </summary>
/// <returns>A collection of all jump instances</returns>
public IEnumerable<Jump> GetAll() public IEnumerable<Jump> GetAll()
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
/// <summary>
/// Retrieves a range of jumps for a specific user
/// </summary>
/// <param name="user">The user whose jumps to retrieve</param>
/// <param name="beginIndex">The starting index</param>
/// <param name="endIndex">The ending index</param>
/// <returns>A collection of jump instances</returns>
public IEnumerable<Jump> GetBetweenIndex(User user, int beginIndex, int endIndex) public IEnumerable<Jump> GetBetweenIndex(User user, int beginIndex, int endIndex)
{ {
return _col.Include(x => x.Aircraft) return _col.Include(x => x.Aircraft)
@@ -70,21 +100,40 @@ namespace skydiveLogs_api.Infrastructure
.ToList(); .ToList();
} }
/// <summary>
/// Retrieves a jump by its unique identifier
/// </summary>
/// <param name="id">The unique identifier of the jump</param>
/// <returns>The jump instance or null if not found</returns>
public Jump GetById(int id) public Jump GetById(int id)
{ {
return _col.FindById(new BsonValue(id)); return _col.FindById(new BsonValue(id));
} }
/// <summary>
/// Gets the total count of jumps for a specific user
/// </summary>
/// <param name="user">The user whose jumps to count</param>
/// <returns>The total number of jumps</returns>
public int GetCount(User user) public int GetCount(User user)
{ {
return _col.Count(j => j.User.Id == user.Id); return _col.Count(j => j.User.Id == user.Id);
} }
/// <summary>
/// Gets the total count of jumps in the database
/// </summary>
/// <returns>The total number of jumps</returns>
public int GetCount() public int GetCount()
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
/// <summary>
/// Updates an existing jump in the database
/// </summary>
/// <param name="updatedJump">The jump instance to update</param>
/// <returns>True if the update was successful, false otherwise</returns>
public bool Update(Jump updatedJump) public bool Update(Jump updatedJump)
{ {
return _col.Update(updatedJump); return _col.Update(updatedJump);
@@ -99,4 +148,4 @@ namespace skydiveLogs_api.Infrastructure
#endregion Private Fields #endregion Private Fields
} }
} }
@@ -1,4 +1,4 @@
using LiteDB; using LiteDB;
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories; using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces; using skydiveLogs_api.Infrastructure.Interfaces;
@@ -11,6 +11,10 @@ namespace skydiveLogs_api.Infrastructure
{ {
#region Public Constructors #region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="JumpTypeRepository"/> class
/// </summary>
/// <param name="dataProvider">The data provider to use for data access</param>
public JumpTypeRepository(IDataProvider dataProvider) public JumpTypeRepository(IDataProvider dataProvider)
{ {
_dataProvider = dataProvider; _dataProvider = dataProvider;
@@ -21,6 +25,11 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods #region Public Methods
/// <summary>
/// Adds a new jump type to the database
/// </summary>
/// <param name="newJumpType">The jump type instance to add</param>
/// <returns>The number of rows affected (0 if insert failed)</returns>
public int Add(JumpType newJumpType) public int Add(JumpType newJumpType)
{ {
int result; int result;
@@ -38,21 +47,39 @@ namespace skydiveLogs_api.Infrastructure
return result; return result;
} }
/// <summary>
/// Retrieves all jump types from the database
/// </summary>
/// <returns>A collection of all jump type instances</returns>
public IEnumerable<JumpType> GetAll() public IEnumerable<JumpType> GetAll()
{ {
return _col.FindAll().ToList(); return _col.FindAll().ToList();
} }
/// <summary>
/// Retrieves a jump type by its unique identifier
/// </summary>
/// <param name="id">The unique identifier of the jump type</param>
/// <returns>The jump type instance or null if not found</returns>
public JumpType GetById(int id) public JumpType GetById(int id)
{ {
return _col.FindById(new BsonValue(id)); return _col.FindById(new BsonValue(id));
} }
/// <summary>
/// Gets the total count of jump types in the database
/// </summary>
/// <returns>The total number of jump types</returns>
public int GetCount() public int GetCount()
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
/// <summary>
/// Updates an existing jump type in the database
/// </summary>
/// <param name="updatedJumpType">The jump type instance to update</param>
/// <returns>True if the update was successful, false otherwise</returns>
public bool Update(JumpType updatedJumpType) public bool Update(JumpType updatedJumpType)
{ {
return _col.Update(updatedJumpType); return _col.Update(updatedJumpType);
@@ -67,4 +94,4 @@ namespace skydiveLogs_api.Infrastructure
#endregion Private Fields #endregion Private Fields
} }
} }
@@ -1,4 +1,4 @@
using LiteDB; using LiteDB;
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories; using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces; using skydiveLogs_api.Infrastructure.Interfaces;
@@ -11,6 +11,10 @@ namespace skydiveLogs_api.Infrastructure
{ {
#region Public Constructors #region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="UserRepository"/> class
/// </summary>
/// <param name="dataProvider">The data provider to use for data access</param>
public UserRepository(IDataProvider dataProvider) public UserRepository(IDataProvider dataProvider)
{ {
_dataProvider = dataProvider; _dataProvider = dataProvider;
@@ -21,6 +25,11 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods #region Public Methods
/// <summary>
/// Adds a new user to the database
/// </summary>
/// <param name="newUser">The user instance to add</param>
/// <returns>The number of rows affected (0 if insert failed)</returns>
public int Add(User newUser) public int Add(User newUser)
{ {
int result; int result;
@@ -38,26 +47,50 @@ namespace skydiveLogs_api.Infrastructure
return result; return result;
} }
/// <summary>
/// Retrieves all users from the database
/// </summary>
/// <returns>A collection of all user instances</returns>
public IEnumerable<User> GetAll() public IEnumerable<User> GetAll()
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
/// <summary>
/// Retrieves a user by its unique identifier
/// </summary>
/// <param name="id">The unique identifier of the user</param>
/// <returns>The user instance or null if not found</returns>
public User GetById(int id) public User GetById(int id)
{ {
return _col.FindById(new BsonValue(id)); return _col.FindById(new BsonValue(id));
} }
/// <summary>
/// Retrieves a user by their login credentials
/// </summary>
/// <param name="login">The user's login</param>
/// <param name="password">The user's password</param>
/// <returns>The user instance or null if not found</returns>
public User GetByLogin(string login, string password) public User GetByLogin(string login, string password)
{ {
return _col.FindOne(u => u.Login == login && u.Password == password); return _col.FindOne(u => u.Login == login && u.Password == password);
} }
/// <summary>
/// Gets the total count of users in the database
/// </summary>
/// <returns>The total number of users</returns>
public int GetCount() public int GetCount()
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
/// <summary>
/// Updates an existing user in the database
/// </summary>
/// <param name="updated">The user instance to update</param>
/// <returns>True if the update was successful, false otherwise</returns>
public bool Update(User updated) public bool Update(User updated)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
@@ -72,4 +105,4 @@ namespace skydiveLogs_api.Infrastructure
#endregion Private Fields #endregion Private Fields
} }
} }