Little test with AI + Add the equipment (#8)

Tests using local LLM AI to add comments in the C# files
For the flights tunnel, show the total to day/hours
For the jump, add the equipment (now just with the wingsuit)

Reviewed-on: #8
Co-authored-by: sandre <perso@sebastienandre.com>
Co-committed-by: sandre <perso@sebastienandre.com>
This commit was merged in pull request #8.
This commit is contained in:
2026-05-16 09:24:13 +00:00
committed by sandre
parent 0ebdbca549
commit ceed44f997
70 changed files with 12142 additions and 10444 deletions
+7 -1
View File
@@ -4,14 +4,20 @@
{
#region Public Properties
public string Aad { get; set; }
public int Id { get; set; }
public string Aad { get; set; }
public string MainCanopy { get; set; }
public string Manufacturer { get; set; }
public int MaxSize { get; set; }
public int MinSize { get; set; }
public string Name { get; set; }
public string ReserveCanopy { get; set; }
public User User { get; set; }
+17 -5
View File
@@ -6,20 +6,32 @@ namespace skydiveLogs_api.Domain
{
#region Public Properties
public Aircraft Aircraft { get; set; }
public int DeployAltitude { get; set; }
public DropZone DropZone { get; set; }
public int ExitAltitude { get; set; }
public Gear Gear { get; set; }
public int Id { get; set; }
public Aircraft Aircraft { get; set; }
public int DeployAltitude { get; set; }
public DropZone DropZone { get; set; }
public int ExitAltitude { get; set; }
public Gear Gear { get; set; }
public bool IsSpecial { get; set; }
public DateTime JumpDate { get; set; }
public JumpType JumpType { get; set; }
public string Notes { get; set; }
public User User { get; set; }
public bool WithCutaway { get; set; }
public string Equipment { get; set; }
#endregion Public Properties
}
}
@@ -11,6 +11,11 @@ namespace skydiveLogs_api.DomainBusiness
{
#region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="AircraftService"/> class.
/// </summary>
/// <param name="aircraftRepository">The aircraft repository for data access.</param>
/// <param name="cacheService">The cache service for caching operations.</param>
public AircraftService(IAircraftRepository aircraftRepository,
ICacheService cacheService)
{
@@ -22,23 +27,40 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Adds a new aircraft to the system.
/// </summary>
/// <param name="newAircraft">The Aircraft entity containing the data for the new aircraft.</param>
public void AddNewAircraft(Aircraft newAircraft)
{
_aircraftRepository.Add(newAircraft);
_cacheService.Delete(CacheType.Aircraft);
}
/// <summary>
/// Deletes an aircraft by its ID.
/// </summary>
/// <param name="id">The aircraft ID to delete.</param>
public void DeleteAircraftById(int id)
{
throw new NotImplementedException();
}
/// <summary>
/// Retrieves an aircraft by its ID.
/// </summary>
/// <param name="id">The aircraft ID to retrieve.</param>
/// <returns>An Aircraft entity containing the aircraft details.</returns>
public Aircraft GetAircraftById(int id)
{
var allAircrafts = GetAllAircrafts();
return allAircrafts.Single(g => g.Id == id);
}
/// <summary>
/// Retrieves all aircrafts.
/// </summary>
/// <returns>A collection of Aircraft entities containing all aircraft data.</returns>
public IEnumerable<Aircraft> GetAllAircrafts()
{
if (!_cacheService.Contains(CacheType.Aircraft))
@@ -49,6 +71,13 @@ namespace skydiveLogs_api.DomainBusiness
return _cacheService.Get<IEnumerable<Aircraft>>(CacheType.Aircraft);
}
/// <summary>
/// Updates an existing aircraft.
/// </summary>
/// <param name="id">The aircraft ID to update.</param>
/// <param name="aircraft">Aircraft entity containing the updated aircraft data.</param>
/// <param name="resetCache">Whether to reset the cache after update.</param>
/// <returns>True if the update was successful, false otherwise.</returns>
public bool UpdateAircraft(int id, Aircraft aircraft, bool resetCache = true)
{
aircraft.Id = id;
@@ -24,24 +24,50 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Checks if a specific cache entry exists for a given type and user ID.
/// </summary>
/// <param name="type">The type of data to check for in the cache.</param>
/// <param name="userId">Optional user ID to distinguish cache entries. Default is 0.</param>
/// <returns>True if the cache entry exists and is valid, otherwise false.</returns>
public bool Contains(CacheType type, int userId = 0)
{
var key = GetKey(userId, type);
return _memoryCache.Contains(key.ToString());
}
/// <summary>
/// Removes a cache entry from the store.
/// </summary>
/// <param name="type">The type of data to remove from the cache.</param>
/// <param name="userId">Optional user ID to identify the cache entry. Default is 0.</param>
public void Delete(CacheType type, int userId = 0)
{
var key = GetKey(userId, type);
_memoryCache.Remove(key.ToString());
}
/// <summary>
/// Retrieves data from the cache for a specified type and user ID.
/// </summary>
/// <typeparam name="T">The expected type of the cached data.</typeparam>
/// <param name="type">The type of data to retrieve from the cache.</param>
/// <param name="userId">Optional user ID to identify the cache entry. Default is 0.</param>
/// <returns>The cached data cast to type T, or default(T) if not found or expired.</returns>
public T Get<T>(CacheType type, int userId = 0)
{
var key = GetKey(userId, type);
return (T)_memoryCache.Get(key.ToString());
}
/// <summary>
/// Stores data in the cache with a specified expiry time.
/// </summary>
/// <param name="type">The unique identifier for the cache key.</param>
/// <param name="value">The object data to be cached.</param>
/// <param name="duration">The duration in milliseconds before the cache entry expires.</param>
/// <param name="userId">Optional user ID to distinguish cache entries. Default is 0.</param>
/// <exception cref="ArgumentException">Thrown when duration is less than or equal to zero.</exception>
public void Put(CacheType type, object value, int duration, int userId = 0)
{
var key = GetKey(userId, type);
@@ -56,6 +82,12 @@ namespace skydiveLogs_api.DomainBusiness
_memoryCache.Set(key.ToString(), value, policy);
}
/// <summary>
/// Generates a cache key by combining the user ID and cache type.
/// </summary>
/// <param name="userId">The user ID to include in the key.</param>
/// <param name="type">The cache type to include in the key.</param>
/// <returns>A concatenated string key combining userId and type.</returns>
private string GetKey(int userId, CacheType type)
{
return $"{userId}-{type}";
@@ -26,12 +26,21 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Adds a new drop zone to the system.
/// </summary>
/// <param name="newdropZone">The DropZone entity containing the new drop zone data.</param>
public void AddNewDz(DropZone newdropZone)
{
_dropZoneRepository.Add(newdropZone);
_cacheService.Delete(CacheType.DropZone);
}
/// <summary>
/// Adds a drop zone to the user's favorites.
/// </summary>
/// <param name="dzId">The drop zone ID to add to favorites.</param>
/// <returns>True if the drop zone was added to favorites, false otherwise.</returns>
public bool AddToFavorite(int dzId)
{
var dzToAddToFavorite = GetDzById(dzId);
@@ -47,11 +56,19 @@ namespace skydiveLogs_api.DomainBusiness
return result > 0;
}
/// <summary>
/// Deletes a drop zone by its ID.
/// </summary>
/// <param name="id">The drop zone ID to delete.</param>
public void DeleteDzById(int id)
{
throw new NotImplementedException();
}
/// <summary>
/// Retrieves a list of all drop zones with favorites status.
/// </summary>
/// <returns>A collection of DropZone entities containing all drop zones with their favorite status.</returns>
public IEnumerable<DropZone> GetAllDzs()
{
var results = Enumerable.Empty<DropZone>();
@@ -78,12 +95,22 @@ namespace skydiveLogs_api.DomainBusiness
return results.ToList();
}
/// <summary>
/// Retrieves a drop zone by its ID.
/// </summary>
/// <param name="id">The drop zone ID to retrieve.</param>
/// <returns>A DropZone entity containing the drop zone details.</returns>
public DropZone GetDzById(int id)
{
var allDzs = GetAllRefDzs();
return allDzs.Single(g => g.Id == id);
}
/// <summary>
/// Removes a drop zone from the user's favorites.
/// </summary>
/// <param name="dzId">The drop zone ID to remove from favorites.</param>
/// <returns>True if the drop zone was removed from favorites, false otherwise.</returns>
public bool RemoveToFavorite(int dzId)
{
var result = _favoriteDropZoneRepository.Delete(dzId, _identityService.ConnectedUser.Id);
@@ -92,6 +119,13 @@ namespace skydiveLogs_api.DomainBusiness
return result > 0;
}
/// <summary>
/// Updates an existing drop zone.
/// </summary>
/// <param name="id">The drop zone ID to update.</param>
/// <param name="dropZone">DropZone entity containing the updated drop zone data.</param>
/// <param name="resetCache">Whether to reset the cache after update.</param>
/// <returns>True if the update was successful, false otherwise.</returns>
public bool UpdateDz(int id, DropZone dropZone, bool resetCache = true)
{
dropZone.Id = id;
@@ -24,6 +24,10 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Adds a new gear item to the system.
/// </summary>
/// <param name="newGear">The Gear entity containing the new gear data.</param>
public void AddNewGear(Gear newGear)
{
newGear.User = _identityService.ConnectedUser;
@@ -33,6 +37,10 @@ namespace skydiveLogs_api.DomainBusiness
_cacheService.Delete(CacheType.Gear, userId: userId);
}
/// <summary>
/// Adds rental gear to the system for a new user.
/// </summary>
/// <param name="newUser">The new user for whom rental gear should be added.</param>
public void AddRentalGear(User newUser)
{
var rentalGear = new Gear
@@ -50,11 +58,19 @@ namespace skydiveLogs_api.DomainBusiness
_gearRepository.Add(rentalGear);
}
/// <summary>
/// Deletes a gear item by its ID.
/// </summary>
/// <param name="id">The gear ID to delete.</param>
public void DeleteGearById(int id)
{
throw new NotImplementedException();
}
/// <summary>
/// Retrieves all gear items.
/// </summary>
/// <returns>A collection of Gear entities containing all gear data.</returns>
public IEnumerable<Gear> GetAllGears()
{
var userId = _identityService.ConnectedUser.Id;
@@ -67,17 +83,33 @@ namespace skydiveLogs_api.DomainBusiness
return _cacheService.Get<IEnumerable<Gear>>(CacheType.Gear, userId: userId);
}
/// <summary>
/// Retrieves a gear item by its ID.
/// </summary>
/// <param name="id">The gear ID to retrieve.</param>
/// <returns>A Gear entity containing the gear details.</returns>
public Gear GetGearById(int id)
{
var allGears = GetAllGears();
return allGears.Single(g => g.Id == id);
}
/// <summary>
/// Updates an existing gear item.
/// </summary>
/// <param name="id">The gear ID to update.</param>
/// <param name="gear">Gear entity containing the updated gear data.</param>
/// <returns>True if the update was successful, false otherwise.</returns>
public bool UpdateGear(int id, Gear gear)
{
gear.Id = id;
gear.User = _identityService.ConnectedUser;
return _gearRepository.Update(gear);
var tmp = _gearRepository.Update(gear);
var userId = _identityService.ConnectedUser.Id;
_cacheService.Delete(CacheType.Gear, userId: userId);
return tmp;
}
#endregion Public Methods
@@ -27,6 +27,9 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Updates the existing data in the database.
/// </summary>
public void Update()
{
UpdateAircrafts();
@@ -38,6 +41,9 @@ namespace skydiveLogs_api.DomainBusiness
_cacheService.Delete(CacheType.JumpType);
}
/// <summary>
/// Generates the database structure and initial data.
/// </summary>
public void GenerateDb()
{
LoadAircrafts();
@@ -28,6 +28,14 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Adds a new jump to the system.
/// </summary>
/// <param name="aircraftId">The ID of the aircraft to use for this jump.</param>
/// <param name="dzId">The ID of the drop zone for this jump.</param>
/// <param name="jumpTypeId">The ID of the jump type for this jump.</param>
/// <param name="gearId">The ID of the gear for this jump.</param>
/// <param name="jump">Jump entity containing the new jump data.</param>
public void AddNewJump(int aircraftId,
int dzId,
int jumpTypeId,
@@ -48,37 +56,66 @@ namespace skydiveLogs_api.DomainBusiness
_jumpRepository.Add(jump);
}
/// <summary>
/// Deletes a jump by its ID.
/// </summary>
/// <param name="id">The jump ID to delete.</param>
public void DeleteJumpById(int id)
{
_jumpRepository.DeleteById(id);
}
/// <summary>
/// Retrieves all jumps for the current user.
/// </summary>
/// <returns>A collection of Jump entities containing all jumps.</returns>
public IEnumerable<Jump> GetAllJumps()
{
return _jumpRepository.GetAll(_identityService.ConnectedUser);
}
/// <summary>
/// Retrieves a jump by its ID.
/// </summary>
/// <param name="id">The jump ID to retrieve.</param>
/// <returns>A Jump entity containing the jump details.</returns>
public Jump GetJumpById(int id)
{
return _jumpRepository.GetById(id);
}
/// <summary>
/// Retrieves the total count of jumps for the current user.
/// </summary>
/// <returns>The total number of jumps.</returns>
public int GetJumpCount()
{
return _jumpRepository.GetCount(_identityService.ConnectedUser);
}
/// <summary>
/// Retrieves a range of jumps for the current user with pagination.
/// </summary>
/// <param name="beginIndex">The starting index for pagination.</param>
/// <param name="endIndex">The ending index for pagination.</param>
/// <returns>A collection of Jump entities containing the requested range.</returns>
public IEnumerable<Jump> GetJumpsByIndexes(int beginIndex, int endIndex)
{
return _jumpRepository.GetBetweenIndex(_identityService.ConnectedUser, beginIndex, endIndex);
}
/// <summary>
/// Updates an existing jump.
/// </summary>
/// <param name="id">The jump ID to update.</param>
/// <param name="updatedJump">Jump entity containing the updated jump data.</param>
public void UpdateJump(int id, Jump updatedJump)
{
var myJump = GetJumpById(id);
myJump.IsSpecial = updatedJump.IsSpecial;
myJump.WithCutaway = updatedJump.WithCutaway;
myJump.Notes = updatedJump.Notes;
myJump.Equipment = updatedJump.Equipment;
_jumpRepository.Update(myJump);
}
@@ -22,17 +22,29 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Adds a new jump type to the system.
/// </summary>
/// <param name="newJumpType">The JumpType entity containing the new jump type data.</param>
public void AddNewJumpType(JumpType newJumpType)
{
_jumpTypeRepository.Add(newJumpType);
_cacheService.Delete(CacheType.JumpType);
}
/// <summary>
/// Deletes a jump type by its ID.
/// </summary>
/// <param name="id">The jump type ID to delete.</param>
public void DeleteJumpTypeById(int id)
{
throw new NotImplementedException();
}
/// <summary>
/// Retrieves all jump types.
/// </summary>
/// <returns>A collection of JumpType entities containing all jump types.</returns>
public IEnumerable<JumpType> GetAllJumpTypes()
{
if (!_cacheService.Contains(CacheType.JumpType))
@@ -43,17 +55,33 @@ namespace skydiveLogs_api.DomainBusiness
return _cacheService.Get<IEnumerable<JumpType>>(CacheType.JumpType);
}
/// <summary>
/// Retrieves jump types specifically used for tunnel operations.
/// </summary>
/// <returns>A collection of JumpType entities containing tunnel jump types.</returns>
public IEnumerable<JumpType> GetJumpTypesForTunnel()
{
return GetAllJumpTypes().Where(t => t.InTunnel);
}
/// <summary>
/// Retrieves a jump type by its ID.
/// </summary>
/// <param name="id">The jump type ID to retrieve.</param>
/// <returns>A JumpType entity containing the jump type details.</returns>
public JumpType GetJumpTypeById(int id)
{
var allJumpTypes = GetAllJumpTypes();
return allJumpTypes.Single(g => g.Id == id);
}
/// <summary>
/// Updates an existing jump type.
/// </summary>
/// <param name="id">The jump type ID to update.</param>
/// <param name="jumpType">JumpType entity containing the updated jump type data.</param>
/// <param name="resetCache">Whether to reset the cache after update.</param>
/// <returns>True if the update was successful, false otherwise.</returns>
public bool UpdateJumpType(int id, JumpType jumpType, bool resetCache = true)
{
jumpType.Id = id;
@@ -1,8 +1,8 @@
using skydiveLogs_api.Domain;
using System.Collections.Generic;
using System.Linq;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainBusiness.Interfaces;
using skydiveLogs_api.DomainService.Repositories;
using System.Collections.Generic;
using System.Linq;
namespace skydiveLogs_api.DomainBusiness
{
@@ -23,6 +23,10 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Retrieves statistics grouped by aircraft.
/// </summary>
/// <returns>A collection of StatsByAircraft entities containing the statistics.</returns>
public IEnumerable<StatsByAircraft> GetStats()
{
var allStats = _statsByAircraftRepository.GetAll(_identityService.ConnectedUser);
@@ -50,6 +54,9 @@ namespace skydiveLogs_api.DomainBusiness
return allStats;
}
/// <summary>
/// Resets the aircraft statistics.
/// </summary>
public void Reset()
{
_statsByAircraftRepository.Delete(_identityService.ConnectedUser);
@@ -1,8 +1,8 @@
using skydiveLogs_api.Domain;
using System.Collections.Generic;
using System.Linq;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainBusiness.Interfaces;
using skydiveLogs_api.DomainService.Repositories;
using System.Collections.Generic;
using System.Linq;
namespace skydiveLogs_api.DomainBusiness
{
@@ -23,6 +23,10 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Retrieves statistics grouped by drop zone.
/// </summary>
/// <returns>A collection of StatsByDz entities containing the statistics.</returns>
public IEnumerable<StatsByDz> GetStats()
{
var allStats = _statsByDzRepository.GetAll(_identityService.ConnectedUser);
@@ -50,6 +54,9 @@ namespace skydiveLogs_api.DomainBusiness
return allStats;
}
/// <summary>
/// Resets the drop zone statistics.
/// </summary>
public void Reset()
{
_statsByDzRepository.Delete(_identityService.ConnectedUser);
@@ -1,8 +1,8 @@
using skydiveLogs_api.Domain;
using System.Collections.Generic;
using System.Linq;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainBusiness.Interfaces;
using skydiveLogs_api.DomainService.Repositories;
using System.Collections.Generic;
using System.Linq;
namespace skydiveLogs_api.DomainBusiness
{
@@ -23,6 +23,10 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Retrieves statistics grouped by gear.
/// </summary>
/// <returns>A collection of StatsByGear entities containing the statistics.</returns>
public IEnumerable<StatsByGear> GetStats()
{
var allStats = _statsByGearRepository.GetAll(_identityService.ConnectedUser);
@@ -50,6 +54,9 @@ namespace skydiveLogs_api.DomainBusiness
return allStats;
}
/// <summary>
/// Resets the gear statistics.
/// </summary>
public void Reset()
{
_statsByGearRepository.Delete(_identityService.ConnectedUser);
@@ -23,6 +23,10 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Retrieves statistics grouped by jump type.
/// </summary>
/// <returns>A collection of StatsByJumpType entities containing the statistics.</returns>
public IEnumerable<StatsByJumpType> GetStats()
{
var allStats = _statsByJumpTypeRepository.GetAll(_identityService.ConnectedUser);
@@ -50,6 +54,9 @@ namespace skydiveLogs_api.DomainBusiness
return allStats;
}
/// <summary>
/// Resets the year and jump type statistics.
/// </summary>
public void Reset()
{
_statsByJumpTypeRepository.Delete(_identityService.ConnectedUser);
@@ -23,6 +23,10 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Retrieves statistics grouped by year and jump type.
/// </summary>
/// <returns>A collection of StatsByYearByJumpType entities containing the statistics.</returns>
public IEnumerable<StatsByYearByJumpType> GetStats()
{
var allStats = _statsByYearByJumpTypeRepository.GetAll(_identityService.ConnectedUser);
@@ -51,6 +55,9 @@ namespace skydiveLogs_api.DomainBusiness
return allStats;
}
/// <summary>
/// Resets the last year by jump type statistics.
/// </summary>
public void Reset()
{
_statsByYearByJumpTypeRepository.Delete(_identityService.ConnectedUser);
@@ -23,6 +23,10 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Retrieves statistics grouped by year.
/// </summary>
/// <returns>A collection of StatsByYear entities containing the statistics.</returns>
public IEnumerable<StatsByYear> GetStats()
{
var allStats = _statsByYearRepository.GetAll(_identityService.ConnectedUser);
@@ -50,6 +54,9 @@ namespace skydiveLogs_api.DomainBusiness
return allStats;
}
/// <summary>
/// Resets the year statistics.
/// </summary>
public void Reset()
{
_statsByYearRepository.Delete(_identityService.ConnectedUser);
@@ -23,6 +23,10 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Retrieves statistics for the last month grouped by drop zone.
/// </summary>
/// <returns>A collection of StatsForLastMonthByDz entities containing the statistics.</returns>
public IEnumerable<StatsForLastMonthByDz> GetStats()
{
var allStats = _statsForLastMonthByDzRepository.GetAll(_identityService.ConnectedUser);
@@ -55,6 +59,9 @@ namespace skydiveLogs_api.DomainBusiness
return allStats;
}
/// <summary>
/// Resets the last month drop zone statistics.
/// </summary>
public void Reset()
{
_statsForLastMonthByDzRepository.Delete(_identityService.ConnectedUser);
@@ -23,6 +23,10 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Retrieves statistics for the last month grouped by jump type.
/// </summary>
/// <returns>A collection of StatsForLastMonthByJumpType entities containing the statistics.</returns>
public IEnumerable<StatsForLastMonthByJumpType> GetStats()
{
var allStats = _statsForLastMonthByJumpTypeRepository.GetAll(_identityService.ConnectedUser);
@@ -55,6 +59,9 @@ namespace skydiveLogs_api.DomainBusiness
return allStats;
}
/// <summary>
/// Resets the last month jump type statistics.
/// </summary>
public void Reset()
{
_statsForLastMonthByJumpTypeRepository.Delete(_identityService.ConnectedUser);
@@ -23,6 +23,10 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Retrieves statistics for the last year grouped by drop zone.
/// </summary>
/// <returns>A collection of StatsForLastYearByDz entities containing the statistics.</returns>
public IEnumerable<StatsForLastYearByDz> GetStats()
{
var allStats = _statsForLastYearByDzRepository.GetAll(_identityService.ConnectedUser);
@@ -54,6 +58,9 @@ namespace skydiveLogs_api.DomainBusiness
return allStats;
}
/// <summary>
/// Resets the last year drop zone statistics.
/// </summary>
public void Reset()
{
_statsForLastYearByDzRepository.Delete(_identityService.ConnectedUser);
@@ -23,6 +23,10 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Retrieves statistics for the last year grouped by jump type.
/// </summary>
/// <returns>A collection of StatsForLastYearByJumpType entities containing the statistics.</returns>
public IEnumerable<StatsForLastYearByJumpType> GetStats()
{
var allStats = _statsForLastYearByJumpTypeRepository.GetAll(_identityService.ConnectedUser);
@@ -54,7 +58,9 @@ namespace skydiveLogs_api.DomainBusiness
return allStats;
}
/// <summary>
/// Resets the last year jump type statistics.
/// </summary>
public void Reset()
{
_statsForLastYearByJumpTypeRepository.Delete(_identityService.ConnectedUser);
@@ -38,6 +38,10 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Retrieves a simple summary of all statistics.
/// </summary>
/// <returns>A SimpleSummary entity containing the simple summary statistics.</returns>
public SimpleSummary GetSimpleSummary()
{
var allJumps = _jumpService.GetAllJumps();
@@ -58,6 +62,9 @@ namespace skydiveLogs_api.DomainBusiness
return results;
}
/// <summary>
/// Resets all statistics.
/// </summary>
public void Reset()
{
_statsByAircraftService.Reset();
@@ -72,6 +79,10 @@ namespace skydiveLogs_api.DomainBusiness
_statsForLastYearByJumpTypeService.Reset();
}
/// <summary>
/// Retrieves statistics grouped by aircraft.
/// </summary>
/// <returns>A collection of Statistic entities containing aircraft statistics.</returns>
public IEnumerable<Statistic> GetStatsByAircraft()
{
var tmp = _statsByAircraftService.GetStats();
@@ -82,6 +93,10 @@ namespace skydiveLogs_api.DomainBusiness
})];
}
/// <summary>
/// Retrieves statistics grouped by drop zone.
/// </summary>
/// <returns>A collection of Statistic entities containing drop zone statistics.</returns>
public IEnumerable<Statistic> GetStatsByDz()
{
var tmp = _statsByDzService.GetStats();
@@ -92,6 +107,10 @@ namespace skydiveLogs_api.DomainBusiness
})];
}
/// <summary>
/// Retrieves statistics grouped by gear.
/// </summary>
/// <returns>A collection of Statistic entities containing gear statistics.</returns>
public IEnumerable<Statistic> GetStatsByGear()
{
var tmp = _statsByGearService.GetStats();
@@ -102,6 +121,10 @@ namespace skydiveLogs_api.DomainBusiness
})];
}
/// <summary>
/// Retrieves statistics grouped by jump type.
/// </summary>
/// <returns>A collection of Statistic entities containing jump type statistics.</returns>
public IEnumerable<Statistic> GetStatsByJumpType()
{
var tmp = _statsByJumpTypeService.GetStats();
@@ -112,6 +135,10 @@ namespace skydiveLogs_api.DomainBusiness
})];
}
/// <summary>
/// Retrieves statistics grouped by year.
/// </summary>
/// <returns>A collection of Statistic entities containing year statistics.</returns>
public IEnumerable<Statistic> GetStatsByYear()
{
var tmp = _statsByYearService.GetStats();
@@ -122,6 +149,10 @@ namespace skydiveLogs_api.DomainBusiness
})];
}
/// <summary>
/// Retrieves statistics for the last month grouped by drop zone.
/// </summary>
/// <returns>A collection of Statistic entities containing last month drop zone statistics.</returns>
public IEnumerable<Statistic> GetStatsForLastMonthByDz()
{
var tmp = _statsForLastMonthByDzService.GetStats();
@@ -132,6 +163,10 @@ namespace skydiveLogs_api.DomainBusiness
})];
}
/// <summary>
/// Retrieves statistics for the last month grouped by jump type.
/// </summary>
/// <returns>A collection of Statistic entities containing last month jump type statistics.</returns>
public IEnumerable<Statistic> GetStatsForLastMonthByJumpType()
{
var tmp = _statsForLastMonthByJumpTypeService.GetStats();
@@ -142,6 +177,10 @@ namespace skydiveLogs_api.DomainBusiness
})];
}
/// <summary>
/// Retrieves statistics for the last year grouped by drop zone.
/// </summary>
/// <returns>A collection of Statistic entities containing last year drop zone statistics.</returns>
public IEnumerable<Statistic> GetStatsForLastYearByDz()
{
var tmp = _statsForLastYearByDzService.GetStats();
@@ -152,6 +191,10 @@ namespace skydiveLogs_api.DomainBusiness
})];
}
/// <summary>
/// Retrieves statistics for the last year grouped by jump type.
/// </summary>
/// <returns>A collection of Statistic entities containing last year jump type statistics.</returns>
public IEnumerable<Statistic> GetStatsForLastYearByJumpType()
{
var tmp = _statsForLastYearByJumpTypeService.GetStats();
@@ -162,6 +205,10 @@ namespace skydiveLogs_api.DomainBusiness
})];
}
/// <summary>
/// Retrieves statistics by year grouped with jump type.
/// </summary>
/// <returns>A collection of Statistic entities containing yearly jump type statistics.</returns>
public IEnumerable<Statistic> GetStatsByYearByJumpType()
{
var tmp = _statsByYearByJumpTypeService.GetStats();
@@ -26,26 +26,51 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Retrieves all tunnel flights.
/// </summary>
/// <returns>A collection of TunnelFlight entities containing all tunnel flights.</returns>
public IEnumerable<TunnelFlight> GetAllTunnelFlights()
{
return _tunnelFlightRepository.GetAll(_identityService.ConnectedUser);
}
/// <summary>
/// Retrieves a tunnel flight by its ID.
/// </summary>
/// <param name="id">The tunnel flight ID to retrieve.</param>
/// <returns>A TunnelFlight entity containing the tunnel flight details.</returns>
public TunnelFlight GetTunnelFlightById(int id)
{
return _tunnelFlightRepository.GetById(id);
}
/// <summary>
/// Retrieves the total count of tunnel flights.
/// </summary>
/// <returns>The total number of tunnel flights.</returns>
public int GetTunnelFlightCount()
{
return _tunnelFlightRepository.GetCount(_identityService.ConnectedUser);
}
/// <summary>
/// Retrieves a range of tunnel flights with pagination.
/// </summary>
/// <param name="beginIndex">The starting index for pagination.</param>
/// <param name="endIndex">The ending index for pagination.</param>
/// <returns>A collection of TunnelFlight entities containing the requested range.</returns>
public IEnumerable<TunnelFlight> GetTunnelFlightsByIndexes(int beginIndex, int endIndex)
{
return _tunnelFlightRepository.GetBetweenIndex(_identityService.ConnectedUser, beginIndex, endIndex);
}
/// <summary>
/// Retrieves tunnel flights grouped by month within a date range.
/// </summary>
/// <param name="beginDate">The start date for grouping.</param>
/// <param name="endDate">The end date for grouping.</param>
/// <returns>A collection of Statistic entities grouped by month.</returns>
public IEnumerable<Statistic> GetTunnelFlightGroupByMonth(string beginDate, string endDate)
{
var convertedBeginDate = Convert.ToDateTime(beginDate);
@@ -69,6 +94,12 @@ namespace skydiveLogs_api.DomainBusiness
return results;
}
/// <summary>
/// Retrieves tunnel flights filtered by date range.
/// </summary>
/// <param name="beginDate">The start date for filtering.</param>
/// <param name="endDate">The end date for filtering.</param>
/// <returns>A collection of TunnelFlight entities filtered by the specified date range.</returns>
public IEnumerable<TunnelFlight> GetTunnelFlightByDates(string beginDate, string endDate)
{
var convertedBeginDate = Convert.ToDateTime(beginDate);
@@ -77,6 +108,12 @@ namespace skydiveLogs_api.DomainBusiness
return _tunnelFlightRepository.GetBetweenDate(_identityService.ConnectedUser, convertedBeginDate, convertedEndDate);
}
/// <summary>
/// Adds a new tunnel flight to the system.
/// </summary>
/// <param name="tunnelId">The tunnel ID to add the flight to.</param>
/// <param name="jumpTypeId">The jump type ID for the flight.</param>
/// <param name="newFlight">TunnelFlight entity containing the new flight data.</param>
public void AddNewFlight(int tunnelId, int jumpTypeId, TunnelFlight newFlight)
{
var tmp = _dropZoneService.GetDzById(tunnelId);
@@ -93,17 +130,25 @@ namespace skydiveLogs_api.DomainBusiness
var selectedJumpType = _jumpTypeService.GetJumpTypeById(jumpTypeId);
newFlight.Tunnel = selectedTunnel;
newFlight.JumpType = selectedJumpType;
_tunnelFlightRepository.Add(newFlight);
}
/// <summary>
/// Deletes a tunnel flight by its ID.
/// </summary>
/// <param name="id">The tunnel flight ID to delete.</param>
public void DeleteTunnelFlightById(int id)
{
_tunnelFlightRepository.DeleteById(id);
}
/// <summary>
/// Updates an existing tunnel flight.
/// </summary>
/// <param name="id">The tunnel flight ID to update.</param>
/// <param name="updatedTunnelFlight">TunnelFlight entity containing the updated tunnel flight data.</param>
public void UpdateTunnelFlight(int id, TunnelFlight updatedTunnelFlight)
{
var myTunnelFlight = GetTunnelFlightById(id);
@@ -24,11 +24,20 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Retrieves all tunnels.
/// </summary>
/// <returns>A collection of Tunnel entities containing all tunnels.</returns>
public IEnumerable<Tunnel> GetAllTunnels()
{
return GetAllRefTunnels();
}
/// <summary>
/// Retrieves a tunnel by its ID.
/// </summary>
/// <param name="id">The tunnel ID to retrieve.</param>
/// <returns>A Tunnel entity containing the tunnel details.</returns>
public Tunnel GetTunnelById(int id)
{
var allTunnels = GetAllRefTunnels();
@@ -21,27 +21,49 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Adds a new image to the system.
/// </summary>
/// <param name="newImage">The UserImage entity containing the new image data.</param>
public void AddNewImage(UserImage newImage)
{
newImage.User = _identityService.ConnectedUser;
_imageRepository.Add(newImage);
}
/// <summary>
/// Deletes an image by its ID.
/// </summary>
/// <param name="id">The image ID to delete.</param>
public void DeleteImageById(int id)
{
throw new NotImplementedException();
}
/// <summary>
/// Retrieves all images.
/// </summary>
/// <returns>A collection of UserImage entities containing all images.</returns>
public IEnumerable<UserImage> GetAllImages()
{
return _imageRepository.GetAll(_identityService.ConnectedUser);
}
/// <summary>
/// Retrieves an image by its ID.
/// </summary>
/// <param name="id">The image ID to retrieve.</param>
/// <returns>A UserImage entity containing the image details.</returns>
public UserImage GetImageById(int id)
{
return _imageRepository.GetById(id);
}
/// <summary>
/// Updates an existing image.
/// </summary>
/// <param name="id">The image ID to update.</param>
/// <param name="Image">UserImage entity containing the updated image data.</param>
public void UpdateImage(int id, UserImage Image)
{
throw new NotImplementedException();
@@ -23,6 +23,11 @@ namespace skydiveLogs_api.DomainBusiness
#region Public Methods
/// <summary>
/// Adds a new user to the system.
/// </summary>
/// <param name="newUser">The User entity containing the new user data.</param>
/// <param name="isAdmin">Whether the new user should have admin privileges.</param>
public bool AddNewUser(User newUser, bool isAdmin = false)
{
newUser.Password = EncryptPassword(newUser.Password);
@@ -45,11 +50,22 @@ namespace skydiveLogs_api.DomainBusiness
return result;
}
/// <summary>
/// Retrieves a user by their ID.
/// </summary>
/// <param name="userId">The user ID to retrieve.</param>
/// <returns>A User entity containing the user details.</returns>
public User GetById(int userId)
{
return _userRepository.GetById(userId);
}
/// <summary>
/// Retrieves a user by their login and password.
/// </summary>
/// <param name="login">The login name of the user.</param>
/// <param name="password">The password to verify the user.</param>
/// <returns>A User entity containing the user details.</returns>
public User GetByLogin(string login, string password)
{
return _userRepository.GetByLogin(login, EncryptPassword(password));
@@ -1,9 +1,10 @@
using LiteDB;
using System;
using System.Collections.Generic;
using System.Linq;
using LiteDB;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces;
using System.Collections.Generic;
using System.Linq;
namespace skydiveLogs_api.Infrastructure
{
@@ -11,6 +12,14 @@ namespace skydiveLogs_api.Infrastructure
{
#region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="AircraftRepository"/> class.
/// </summary>
/// <param name="dataProvider">The data provider used for database access operations</param>
/// <remarks>
/// This constructor initializes the repository with a reference to the data provider
/// and sets up the collection for aircraft data operations.
/// </remarks>
public AircraftRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
@@ -21,6 +30,15 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
/// <summary>
/// Adds a new aircraft to the database.
/// </summary>
/// <param name="newAircraft">The aircraft instance to insert into the database</param>
/// <returns>The number of rows affected. Returns 0 if the insert operation failed.</returns>
/// <remarks>
/// Attempts to insert the new aircraft into the database using LiteDB.
/// If an exception occurs during insertion, the method returns 0.
/// </remarks>
public int Add(Aircraft newAircraft)
{
int result;
@@ -38,21 +56,55 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Retrieves all aircraft from the database.
/// </summary>
/// <returns>An enumerable collection containing all aircraft instances stored in the database</returns>
/// <remarks>
/// Queries the aircraft collection and retrieves all records,
/// then converts the result to a List for enumeration.
/// </remarks>
public IEnumerable<Aircraft> GetAll()
{
return _col.FindAll().ToList();
}
/// <summary>
/// Retrieves an aircraft by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the aircraft to retrieve</param>
/// <returns>The aircraft instance if found, otherwise null</returns>
/// <remarks>
/// Searches the aircraft collection for a record with the specified ID
/// and returns the found aircraft or null if no match exists.
/// </remarks>
public Aircraft GetById(int id)
{
return _col.FindById(new BsonValue(id));
}
/// <summary>
/// Gets the total count of aircraft in the database.
/// </summary>
/// <returns>The total number of aircraft stored in the database</returns>
/// <remarks>
/// This method is not currently implemented and throws
/// a <see cref="NotImplementedException"/> when called.
/// </remarks>
public int GetCount()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Updates an existing aircraft in the database.
/// </summary>
/// <param name="aircraft">The aircraft instance containing the updated data</param>
/// <returns><see langword="true"/> if the update was successful; otherwise, <see langword="false"/></returns>
/// <remarks>
/// Updates the aircraft record in the database with the provided aircraft instance.
/// The method returns the result of the underlying LiteDB update operation.
/// </remarks>
public bool Update(Aircraft aircraft)
{
return _col.Update(aircraft);
@@ -62,7 +114,14 @@ namespace skydiveLogs_api.Infrastructure
#region Private Fields
/// <summary>
/// The LiteDB collection for aircraft records.
/// </summary>
private readonly ILiteCollection<Aircraft> _col;
/// <summary>
/// The data provider used for database access operations.
/// </summary>
private readonly IDataProvider _dataProvider;
#endregion Private Fields
@@ -1,9 +1,10 @@
using LiteDB;
using System;
using System.Collections.Generic;
using System.Linq;
using LiteDB;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces;
using System.Collections.Generic;
using System.Linq;
namespace skydiveLogs_api.Infrastructure
{
@@ -11,6 +12,15 @@ namespace skydiveLogs_api.Infrastructure
{
#region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="DropZoneRepository"/> class.
/// </summary>
/// <param name="dataProvider">The data provider used for database access operations.</param>
/// <remarks>
/// This constructor initializes the repository with a reference to the data provider
/// and sets up the collection for drop zone data operations.
/// The data provider manages the underlying LiteDatabase connection.
/// </remarks>
public DropZoneRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
@@ -21,13 +31,23 @@ namespace skydiveLogs_api.Infrastructure
#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 insert into the database.</param>
/// <returns>The number of rows affected. Returns 0 if the insert operation failed.</returns>
/// <remarks>
/// Attempts to insert the new drop zone into the database using LiteDB.
/// If an exception occurs during insertion, the method returns 0.
/// The returned value indicates the number of records affected by the insert operation.
/// </remarks>
public int Add(DropZone newDropZone)
{
int result;
try
{
var tmp = _col.Insert(newDz);
var tmp = _col.Insert(newDropZone);
result = tmp.AsInt32;
}
catch
@@ -38,31 +58,78 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Retrieves all drop zones from the database.
/// </summary>
/// <returns>An enumerable collection containing all drop zone instances stored in the database.</returns>
/// <remarks>
/// Queries the drop zone collection and retrieves all records,
/// then converts the result to a List for enumeration.
/// Returns an empty list if no drop zones exist in the database.
/// </remarks>
public IEnumerable<DropZone> GetAll()
{
return _col.FindAll().ToList();
}
/// <summary>
/// Retrieves a drop zone by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the drop zone to retrieve.</param>
/// <returns>The drop zone instance if found, otherwise null.</returns>
/// <remarks>
/// Searches the drop zone collection for a record with the specified ID
/// and returns the found drop zone or null if no match exists.
/// Use <see cref="GetAll"/> to retrieve all drop zones or filter by criteria.
/// </remarks>
public DropZone GetById(int 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 stored in the database.</returns>
/// <remarks>
/// This method is not currently implemented and throws
/// a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve the count of all drop zones.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the count is requested.</exception>
public int GetCount()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
public bool Update(DropZone updatedDz)
/// <summary>
/// Updates an existing drop zone in the database.
/// </summary>
/// <param name="dropZone">The drop zone instance containing the updated data.</param>
/// <returns><see langword="true"/> if the update was successful; otherwise, <see langword="false"/>.</returns>
/// <remarks>
/// Updates the drop zone record in the database with the provided drop zone instance.
/// The drop zone must have a valid ID to be updated.
/// The method returns the result of the underlying LiteDB update operation.
/// If the drop zone does not exist, the update operation will return 0.
/// </remarks>
public bool Update(DropZone dropZone)
{
return _col.Update(updatedDz);
return _col.Update(dropZone);
}
#endregion Public Methods
#region Private Fields
/// <summary>
/// The LiteDB collection for drop zone records.
/// </summary>
private readonly ILiteCollection<DropZone> _col;
/// <summary>
/// The data provider used for database access operations.
/// </summary>
private readonly IDataProvider _dataProvider;
#endregion Private Fields
@@ -1,8 +1,9 @@
using LiteDB;
using System;
using System.Collections.Generic;
using LiteDB;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces;
using System.Collections.Generic;
namespace skydiveLogs_api.Infrastructure
{
@@ -10,6 +11,16 @@ namespace skydiveLogs_api.Infrastructure
{
#region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="FavoriteDropZoneRepository"/> class.
/// </summary>
/// <param name="dataProvider">The data provider used for database access operations.</param>
/// <remarks>
/// This constructor initializes the repository with a reference to the data provider
/// and sets up the collection for favorite drop zone data operations.
/// The data provider manages the underlying LiteDatabase connection and provides
/// typed collection accessors for different entity types.
/// </remarks>
public FavoriteDropZoneRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
@@ -20,6 +31,16 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
/// <summary>
/// Adds a new favorite drop zone to the database.
/// </summary>
/// <param name="favoriteToAdd">The favorite drop zone instance to insert into the database.</param>
/// <returns>The number of rows affected. Returns 0 if the insert operation failed.</returns>
/// <remarks>
/// Attempts to insert the new favorite drop zone into the database using LiteDB.
/// If an exception occurs during insertion, the method returns 0.
/// The returned value indicates the number of records affected by the insert operation.
/// </remarks>
public int Add(FavoriteDropZone favoriteToAdd)
{
int result;
@@ -37,11 +58,31 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Deletes favorite drop zone entries by drop zone ID and user ID.
/// </summary>
/// <param name="dropZoneId">The unique identifier of the drop zone to delete favorites for.</param>
/// <param name="userId">The unique identifier of the user whose favorites to delete.</param>
/// <returns>The number of rows affected. Returns 0 if the delete operation failed or no records matched.</returns>
/// <remarks>
/// Deletes all favorite drop zone records where both the drop zone ID and user ID match the provided values.
/// This operation is commonly used to remove a specific user's favorites for a particular drop zone.
/// </remarks>
public int Delete(int dropZoneId, int 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>An enumerable collection containing all favorite drop zone instances belonging to the specified user.</returns>
/// <remarks>
/// Queries the favorite drop zone collection and retrieves all records where the user ID matches the provided user.
/// Each returned record includes navigation properties to the associated user and drop zone entities.
/// Returns an empty collection if the user has no favorite drop zones.
/// </remarks>
public IEnumerable<FavoriteDropZone> GetAll(User user)
{
return _col.Query()
@@ -49,31 +90,79 @@ namespace skydiveLogs_api.Infrastructure
.ToList();
}
/// <summary>
/// Retrieves all favorite drop zones from the database.
/// </summary>
/// <returns>An enumerable collection containing all favorite drop zone instances in the database.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve all favorite drop zones across all users in the system.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the method is called.</exception>
public IEnumerable<FavoriteDropZone> GetAll()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Retrieves a favorite drop zone by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the favorite drop zone to retrieve.</param>
/// <returns>The favorite drop zone instance if found, otherwise null.</returns>
/// <remarks>
/// Searches the favorite drop zone collection for a record with the specified ID.
/// This method currently returns null as it's not implemented with proper filtering by ID.
/// Implement this method to retrieve a specific favorite drop zone by its database ID.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when attempting to retrieve by ID.</exception>
public FavoriteDropZone GetById(int id)
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Gets the total count of favorite drop zones for a specific user.
/// </summary>
/// <param name="user">The user whose favorite drop zones to count.</param>
/// <returns>The total number of favorite drop zones for the specified user.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve the count of favorite drop zones per user.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the method is called.</exception>
public int GetCount()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Updates an existing favorite drop zone in the database.
/// </summary>
/// <param name="updated">The favorite drop zone instance containing the updated data.</param>
/// <returns><see langword="true"/> if the update was successful; otherwise, <see langword="false"/>.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to update existing favorite drop zone records in the database.
/// Note: Favorite drop zones may not typically be updated; consider using Add for new favorites.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when attempting to update.</exception>
public bool Update(FavoriteDropZone updated)
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
#endregion Public Methods
#region Private Fields
/// <summary>
/// The LiteDB collection for favorite drop zone records.
/// </summary>
private readonly ILiteCollection<FavoriteDropZone> _col;
/// <summary>
/// The data provider used for database access operations.
/// </summary>
private readonly IDataProvider _dataProvider;
#endregion Private Fields
@@ -1,8 +1,9 @@
using LiteDB;
using System;
using System.Collections.Generic;
using LiteDB;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces;
using System.Collections.Generic;
namespace skydiveLogs_api.Infrastructure
{
@@ -10,6 +11,16 @@ namespace skydiveLogs_api.Infrastructure
{
#region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="GearRepository"/> class.
/// </summary>
/// <param name="dataProvider">The data provider used for database access operations.</param>
/// <remarks>
/// This constructor initializes the repository with a reference to the data provider
/// and sets up the collection for gear data operations.
/// The data provider manages the underlying LiteDatabase connection and provides
/// typed collection accessors for different entity types.
/// </remarks>
public GearRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
@@ -20,6 +31,17 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
/// <summary>
/// Adds a new gear item to the database.
/// </summary>
/// <param name="newGear">The gear instance to insert into the database.</param>
/// <returns>The number of rows affected. Returns 0 if the insert operation failed.</returns>
/// <remarks>
/// Attempts to insert the new gear item into the database using LiteDB.
/// The gear item should have all required properties set before insertion.
/// If an exception occurs during insertion, the method returns 0.
/// The returned value indicates the number of records affected by the insert operation.
/// </remarks>
public int Add(Gear newGear)
{
int result;
@@ -37,11 +59,30 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Retrieves all gear items from the database.
/// </summary>
/// <returns>An enumerable collection containing all gear instances stored in the database.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve all gear records from the database, potentially filtered by user.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the method is called.</exception>
public IEnumerable<Gear> GetAll()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Retrieves all gear items for a specific user.
/// </summary>
/// <param name="user">The user whose gear items to retrieve.</param>
/// <returns>An enumerable collection containing all gear instances belonging to the specified user.</returns>
/// <remarks>
/// Queries the gear collection and retrieves all records where the user ID matches the provided user.
/// Each returned gear record includes navigation properties to the associated user entity.
/// Returns an empty collection if the user has no gear items.
/// </remarks>
public IEnumerable<Gear> GetAll(User user)
{
return _col.Include(x => x.User)
@@ -50,16 +91,46 @@ namespace skydiveLogs_api.Infrastructure
.ToList();
}
/// <summary>
/// Retrieves a gear item by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the gear item to retrieve.</param>
/// <returns>The gear item instance if found, otherwise null.</returns>
/// <remarks>
/// Searches the gear collection for a record with the specified ID.
/// Returns null if no gear item with the matching ID is found in the database.
/// </remarks>
public Gear GetById(int id)
{
return _col.FindById(new BsonValue(id));
}
/// <summary>
/// Gets the total count of gear items for a specific user.
/// </summary>
/// <param name="user">The user whose gear items to count.</param>
/// <returns>The total number of gear items for the specified user.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve the count of gear items per user.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the method is called.</exception>
public int GetCount()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Updates an existing gear item in the database.
/// </summary>
/// <param name="updatedGear">The gear item instance containing the updated data.</param>
/// <returns><see langword="true"/> if the update was successful; otherwise, <see langword="false"/>.</returns>
/// <remarks>
/// Updates the gear record in the database with the provided gear item instance.
/// The gear item must have a valid ID to be updated.
/// The method returns the result of the underlying LiteDB update operation.
/// If the gear item does not exist, the update operation will return 0.
/// </remarks>
public bool Update(Gear updatedGear)
{
return _col.Update(updatedGear);
@@ -69,7 +140,14 @@ namespace skydiveLogs_api.Infrastructure
#region Private Fields
/// <summary>
/// The LiteDB collection for gear records.
/// </summary>
private readonly ILiteCollection<Gear> _col;
/// <summary>
/// The data provider used for database access operations.
/// </summary>
private readonly IDataProvider _dataProvider;
#endregion Private Fields
@@ -1,8 +1,9 @@
using LiteDB;
using System;
using System.Collections.Generic;
using LiteDB;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces;
using System.Collections.Generic;
namespace skydiveLogs_api.Infrastructure
{
@@ -10,6 +11,16 @@ namespace skydiveLogs_api.Infrastructure
{
#region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="JumpRepository"/> class.
/// </summary>
/// <param name="dataProvider">The data provider used for database access operations.</param>
/// <remarks>
/// This constructor initializes the repository with a reference to the data provider
/// and sets up the collection for jump data operations.
/// The data provider manages the underlying LiteDatabase connection and provides
/// typed collection accessors for different entity types.
/// </remarks>
public JumpRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
@@ -20,6 +31,17 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
/// <summary>
/// Adds a new jump record to the database.
/// </summary>
/// <param name="newJump">The jump instance to insert into the database.</param>
/// <returns>The number of rows affected. Returns 0 if the insert operation failed.</returns>
/// <remarks>
/// Attempts to insert the new jump record into the database using LiteDB.
/// The jump record should have all required properties set before insertion.
/// If an exception occurs during insertion, the method returns 0.
/// The returned value indicates the number of records affected by the insert operation.
/// </remarks>
public int Add(Jump newJump)
{
int result;
@@ -37,11 +59,31 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Deletes a jump record by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the jump to delete.</param>
/// <returns><see langword="true"/> if the deletion was successful; otherwise, <see langword="false"/>.</returns>
/// <remarks>
/// Deletes the jump record with the specified ID from the database.
/// The method uses the <see cref="ILiteCollection{T}.Delete"/> method to remove the record.
/// </remarks>
public bool DeleteById(int id)
{
return _col.Delete(new BsonValue(id));
}
/// <summary>
/// Retrieves all jump records for a specific user.
/// </summary>
/// <param name="user">The user whose jump records to retrieve.</param>
/// <returns>An enumerable collection containing all jump records belonging to the specified user.</returns>
/// <remarks>
/// Queries the jump collection and retrieves all records where the user ID matches the provided user.
/// Each returned jump record includes navigation properties to the associated aircraft, drop zone,
/// gear, and jump type entities for eager loading.
/// Returns an empty collection if the user has no jump records.
/// </remarks>
public IEnumerable<Jump> GetAll(User user)
{
return _col.Include(x => x.Aircraft)
@@ -51,11 +93,32 @@ namespace skydiveLogs_api.Infrastructure
.Find(j => j.User.Id == user.Id);
}
/// <summary>
/// Retrieves all jump records from the database.
/// </summary>
/// <returns>An enumerable collection containing all jump records stored in the database.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve all jump records from the database without filtering.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the method is called.</exception>
public IEnumerable<Jump> GetAll()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Retrieves a range of jump records for a specific user with pagination.
/// </summary>
/// <param name="user">The user whose jump records to retrieve.</param>
/// <param name="beginIndex">The starting index for pagination (inclusive).</param>
/// <param name="endIndex">The ending index for pagination (exclusive).</param>
/// <returns>An enumerable collection containing the requested range of jump records.</returns>
/// <remarks>
/// Retrieves a paginated range of jump records for the specified user, ordered by jump date in descending order.
/// Uses LiteDB query operators to limit and offset the results for efficient pagination.
/// Each jump record includes navigation properties to related entities.
/// </remarks>
public IEnumerable<Jump> GetBetweenIndex(User user, int beginIndex, int endIndex)
{
return _col.Include(x => x.Aircraft)
@@ -70,21 +133,60 @@ namespace skydiveLogs_api.Infrastructure
.ToList();
}
/// <summary>
/// Retrieves a jump record by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the jump to retrieve.</param>
/// <returns>The jump record instance if found, otherwise null.</returns>
/// <remarks>
/// Searches the jump collection for a record with the specified ID.
/// Returns null if no jump record with the matching ID is found in the database.
/// </remarks>
public Jump GetById(int id)
{
return _col.FindById(new BsonValue(id));
}
/// <summary>
/// Gets the total count of jump records for a specific user.
/// </summary>
/// <param name="user">The user whose jump records to count.</param>
/// <returns>The total number of jump records for the specified user.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve the count of jump records per user.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the method is called.</exception>
public int GetCount(User user)
{
return _col.Count(j => j.User.Id == user.Id);
}
/// <summary>
/// Gets the total count of jump records in the database.
/// </summary>
/// <returns>The total number of jump records stored in the database.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve the count of all jump records.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the method is called.</exception>
public int GetCount()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Updates an existing jump record in the database.
/// </summary>
/// <param name="updatedJump">The jump record instance containing the updated data.</param>
/// <returns><see langword="true"/> if the update was successful; otherwise, <see langword="false"/>.</returns>
/// <remarks>
/// Updates the jump record in the database with the provided jump record instance.
/// The jump record must have a valid ID to be updated.
/// The method returns the result of the underlying LiteDB update operation.
/// If the jump record does not exist, the update operation will return 0.
/// </remarks>
public bool Update(Jump updatedJump)
{
return _col.Update(updatedJump);
@@ -94,7 +196,14 @@ namespace skydiveLogs_api.Infrastructure
#region Private Fields
/// <summary>
/// The LiteDB collection for jump records.
/// </summary>
private readonly ILiteCollection<Jump> _col;
/// <summary>
/// The data provider used for database access operations.
/// </summary>
private readonly IDataProvider _dataProvider;
#endregion Private Fields
@@ -1,9 +1,10 @@
using LiteDB;
using System;
using System.Collections.Generic;
using System.Linq;
using LiteDB;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces;
using System.Collections.Generic;
using System.Linq;
namespace skydiveLogs_api.Infrastructure
{
@@ -11,6 +12,16 @@ namespace skydiveLogs_api.Infrastructure
{
#region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="JumpTypeRepository"/> class.
/// </summary>
/// <param name="dataProvider">The data provider used for database access operations.</param>
/// <remarks>
/// This constructor initializes the repository with a reference to the data provider
/// and sets up the collection for jump type data operations.
/// The data provider manages the underlying LiteDatabase connection and provides
/// typed collection accessors for different entity types.
/// </remarks>
public JumpTypeRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
@@ -21,6 +32,17 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
/// <summary>
/// Adds a new jump type to the database.
/// </summary>
/// <param name="newJumpType">The jump type instance to insert into the database.</param>
/// <returns>The number of rows affected. Returns 0 if the insert operation failed.</returns>
/// <remarks>
/// Attempts to insert the new jump type into the database using LiteDB.
/// The jump type should have all required properties set before insertion.
/// If an exception occurs during insertion, the method returns 0.
/// The returned value indicates the number of records affected by the insert operation.
/// </remarks>
public int Add(JumpType newJumpType)
{
int result;
@@ -38,21 +60,59 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Retrieves all jump types from the database.
/// </summary>
/// <returns>An enumerable collection containing all jump type instances stored in the database.</returns>
/// <remarks>
/// Queries the jump type collection and retrieves all records,
/// then converts the result to a List for enumeration.
/// Returns an empty list if no jump types exist in the database.
/// </remarks>
public IEnumerable<JumpType> GetAll()
{
return _col.FindAll().ToList();
}
/// <summary>
/// Retrieves a jump type by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the jump type to retrieve.</param>
/// <returns>The jump type instance if found, otherwise null.</returns>
/// <remarks>
/// Searches the jump type collection for a record with the specified ID.
/// Returns null if no jump type with the matching ID is found in the database.
/// </remarks>
public JumpType GetById(int 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 stored in the database.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve the count of all jump type records in the database.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the method is called.</exception>
public int GetCount()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Updates an existing jump type in the database.
/// </summary>
/// <param name="updatedJumpType">The jump type instance containing the updated data.</param>
/// <returns><see langword="true"/> if the update was successful; otherwise, <see langword="false"/>.</returns>
/// <remarks>
/// Updates the jump type record in the database with the provided jump type instance.
/// The jump type must have a valid ID to be updated.
/// The method returns the result of the underlying LiteDB update operation.
/// If the jump type does not exist, the update operation will return 0.
/// </remarks>
public bool Update(JumpType updatedJumpType)
{
return _col.Update(updatedJumpType);
@@ -62,7 +122,14 @@ namespace skydiveLogs_api.Infrastructure
#region Private Fields
/// <summary>
/// The LiteDB collection for jump type records.
/// </summary>
private readonly ILiteCollection<JumpType> _col;
/// <summary>
/// The data provider used for database access operations.
/// </summary>
private readonly IDataProvider _dataProvider;
#endregion Private Fields
@@ -10,6 +10,10 @@ namespace skydiveLogs_api.Infrastructure
{
#region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="StatsByDzRepository"/> class
/// </summary>
/// <param name="dataProvider">The data provider to use for data access</param>
public StatsByDzRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
@@ -20,6 +24,11 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
/// <summary>
/// Adds a new collection of stats by drop zone to the database
/// </summary>
/// <param name="newStats">The collection of stats by drop zone instances to add</param>
/// <returns>The number of rows affected</returns>
public int Add(IEnumerable<StatsByDz> newStats)
{
int result = 0;
@@ -40,6 +49,11 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Retrieves all stats by drop zone for a specific user
/// </summary>
/// <param name="user">The user whose stats by drop zone to retrieve</param>
/// <returns>A collection of stats by drop zone instances belonging to the user</returns>
public IEnumerable<StatsByDz> GetAll(User user)
{
return _col.Include(x => x.User)
@@ -48,6 +62,12 @@ namespace skydiveLogs_api.Infrastructure
.ToList();
}
/// <summary>
/// Updates existing stats by drop zone in the database
/// </summary>
/// <param name="updatedStats">The stats by drop zone instances to update</param>
/// <param name="user">The user whose stats to update</param>
/// <returns>True if the update was successful, false otherwise</returns>
public bool Update(IEnumerable<StatsByDz> updatedStats, User user)
{
Delete(user);
@@ -56,6 +76,11 @@ namespace skydiveLogs_api.Infrastructure
return tmp != 0;
}
/// <summary>
/// Deletes all stats by drop zone for a specific user
/// </summary>
/// <param name="user">The user whose stats by drop zone to delete</param>
/// <returns>True if the delete was successful, false otherwise</returns>
public bool Delete(User user)
{
var tmp = _col.DeleteMany(s => s.User.Id == user.Id);
@@ -10,6 +10,10 @@ namespace skydiveLogs_api.Infrastructure
{
#region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="StatsByGearRepository"/> class
/// </summary>
/// <param name="dataProvider">The data provider to use for data access</param>
public StatsByGearRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
@@ -20,6 +24,11 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
/// <summary>
/// Adds a new collection of stats by gear to the database
/// </summary>
/// <param name="newStats">The collection of stats by gear instances to add</param>
/// <returns>The number of rows affected</returns>
public int Add(IEnumerable<StatsByGear> newStats)
{
int result = 0;
@@ -40,6 +49,11 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Retrieves all stats by gear for a specific user
/// </summary>
/// <param name="user">The user whose stats by gear to retrieve</param>
/// <returns>A collection of stats by gear instances belonging to the user</returns>
public IEnumerable<StatsByGear> GetAll(User user)
{
return _col.Include(x => x.User)
@@ -48,6 +62,12 @@ namespace skydiveLogs_api.Infrastructure
.ToList();
}
/// <summary>
/// Updates existing stats by gear in the database
/// </summary>
/// <param name="updatedStats">The stats by gear instances to update</param>
/// <param name="user">The user whose stats to update</param>
/// <returns>True if the update was successful, false otherwise</returns>
public bool Update(IEnumerable<StatsByGear> updatedStats, User user)
{
Delete(user);
@@ -56,6 +76,11 @@ namespace skydiveLogs_api.Infrastructure
return tmp != 0;
}
/// <summary>
/// Deletes all stats by gear for a specific user
/// </summary>
/// <param name="user">The user whose stats by gear to delete</param>
/// <returns>True if the delete was successful, false otherwise</returns>
public bool Delete(User user)
{
var tmp = _col.DeleteMany(s => s.User.Id == user.Id);
@@ -1,9 +1,9 @@
using LiteDB;
using System;
using System.Collections.Generic;
using LiteDB;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces;
using System;
using System.Collections.Generic;
namespace skydiveLogs_api.Infrastructure
{
@@ -21,6 +21,11 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
/// <summary>
/// Adds a new tunnel flight to the database.
/// </summary>
/// <param name="newTunnelFlight">The tunnel flight instance to insert into the database.</param>
/// <returns>The number of rows affected. Returns 0 if the insert operation failed.</returns>
public int Add(TunnelFlight newTunnelFlight)
{
int result;
@@ -38,11 +43,21 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Deletes a tunnel flight by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the tunnel flight to delete.</param>
/// <returns><see langword="true"/> if the deletion was successful; otherwise, <see langword="false"/>.</returns>
public bool DeleteById(int id)
{
return _col.Delete(new BsonValue(id));
}
/// <summary>
/// Retrieves all tunnel flights for a specific user.
/// </summary>
/// <param name="user">The user whose tunnel flight records to retrieve.</param>
/// <returns>An enumerable collection containing all tunnel flight records belonging to the specified user.</returns>
public IEnumerable<TunnelFlight> GetAll(User user)
{
return _col.Include(x => x.Tunnel)
@@ -50,11 +65,22 @@ namespace skydiveLogs_api.Infrastructure
.Find(j => j.User.Id == user.Id);
}
/// <summary>
/// Retrieves all tunnel flights from the database.
/// </summary>
/// <returns>An enumerable collection containing all tunnel flight records stored in the database.</returns>
public IEnumerable<TunnelFlight> GetAll()
{
throw new System.NotImplementedException();
}
/// <summary>
/// Retrieves a range of tunnel flights for a specific user with pagination.
/// </summary>
/// <param name="user">The user whose tunnel flight records to retrieve.</param>
/// <param name="beginIndex">The starting index for pagination (inclusive).</param>
/// <param name="endIndex">The ending index for pagination (exclusive).</param>
/// <returns>An enumerable collection containing the requested range of tunnel flight records.</returns>
public IEnumerable<TunnelFlight> GetBetweenIndex(User user, int beginIndex, int endIndex)
{
return _col.Include(x => x.Tunnel)
@@ -67,6 +93,13 @@ namespace skydiveLogs_api.Infrastructure
.ToList();
}
/// <summary>
/// Retrieves a range of tunnel flights within a date range for a specific user.
/// </summary>
/// <param name="user">The user whose tunnel flight records to retrieve.</param>
/// <param name="beginDate">The start of the date range (inclusive).</param>
/// <param name="endDate">The end of the date range (exclusive).</param>
/// <returns>An enumerable collection containing the requested range of tunnel flight records within the specified date range.</returns>
public IEnumerable<TunnelFlight> GetBetweenDate(User user, DateTime beginDate, DateTime endDate)
{
return _col.Include(x => x.Tunnel)
@@ -78,21 +111,40 @@ namespace skydiveLogs_api.Infrastructure
.ToList();
}
/// <summary>
/// Retrieves a tunnel flight by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the tunnel flight to retrieve.</param>
/// <returns>The tunnel flight record instance if found, otherwise null.</returns>
public TunnelFlight GetById(int id)
{
return _col.FindById(new BsonValue(id));
}
/// <summary>
/// Gets the total count of tunnel flights for a specific user.
/// </summary>
/// <param name="user">The user whose tunnel flight records to count.</param>
/// <returns>The total number of tunnel flight records for the specified user.</returns>
public int GetCount(User user)
{
return _col.Count(j => j.User.Id == user.Id);
}
/// <summary>
/// Gets the total count of tunnel flights in the database.
/// </summary>
/// <returns>The total number of tunnel flight records stored in the database.</returns>
public int GetCount()
{
throw new System.NotImplementedException();
}
/// <summary>
/// Updates an existing tunnel flight record in the database.
/// </summary>
/// <param name="updatedTunnelFlight">The tunnel flight instance containing the updated data.</param>
/// <returns><see langword="true"/> if the update was successful; otherwise, <see langword="false"/>.</returns>
public bool Update(TunnelFlight updatedTunnelFlight)
{
return _col.Update(updatedTunnelFlight);
@@ -103,6 +155,7 @@ namespace skydiveLogs_api.Infrastructure
#region Private Fields
private readonly ILiteCollection<TunnelFlight> _col;
private readonly IDataProvider _dataProvider;
#endregion Private Fields
@@ -1,8 +1,9 @@
using LiteDB;
using System;
using System.Collections.Generic;
using LiteDB;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces;
using System.Collections.Generic;
namespace skydiveLogs_api.Infrastructure
{
@@ -20,6 +21,17 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
/// <summary>
/// Adds a new user image to the database.
/// </summary>
/// <param name="newImage">The user image instance to insert into the database.</param>
/// <returns>The number of rows affected. Returns 0 if the insert operation failed.</returns>
/// <remarks>
/// Attempts to insert the new user image into the database using LiteDB.
/// The user image should have all required properties set before insertion.
/// If an exception occurs during insertion, the method returns 0.
/// The returned value indicates the number of records affected by the insert operation.
/// </remarks>
public int Add(UserImage newImage)
{
int result;
@@ -37,11 +49,30 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Retrieves all user images from the database.
/// </summary>
/// <returns>An enumerable collection containing all user image instances stored in the database.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve all user image records from the database.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the method is called.</exception>
public IEnumerable<UserImage> GetAll()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Retrieves all user images for a specific user.
/// </summary>
/// <param name="user">The user whose image records to retrieve.</param>
/// <returns>An enumerable collection containing all user image instances belonging to the specified user.</returns>
/// <remarks>
/// Queries the user image collection and retrieves all records where the user ID matches the provided user.
/// Each returned image record includes navigation properties to the associated user entity.
/// Returns an empty collection if the user has no profile images.
/// </remarks>
public IEnumerable<UserImage> GetAll(User user)
{
return _col.Include(x => x.User)
@@ -50,16 +81,46 @@ namespace skydiveLogs_api.Infrastructure
.ToList();
}
/// <summary>
/// Retrieves a user image by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the user image to retrieve.</param>
/// <returns>The user image instance if found, otherwise null.</returns>
/// <remarks>
/// Searches the user image collection for a record with the specified ID.
/// Returns null if no user image with the matching ID is found in the database.
/// </remarks>
public UserImage GetById(int id)
{
return _col.FindById(new BsonValue(id));
}
/// <summary>
/// Gets the total count of user images for a specific user.
/// </summary>
/// <param name="user">The user whose image records to count.</param>
/// <returns>The total number of user image records for the specified user.</returns>
/// <remarks>
/// This method is not currently implemented and throws a <see cref="NotImplementedException"/> when called.
/// Implement this method to retrieve the count of user image records per user.
/// </remarks>
/// <exception cref="NotImplementedException">Thrown when the method is called.</exception>
public int GetCount()
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
/// <summary>
/// Updates an existing user image record in the database.
/// </summary>
/// <param name="image">The user image instance containing the updated data.</param>
/// <returns><see langword="true"/> if the update was successful; otherwise, <see langword="false"/>.</returns>
/// <remarks>
/// Updates the user image record in the database with the provided image instance.
/// The user image must have a valid ID to be updated.
/// The method returns the result of the underlying LiteDB update operation.
/// If the user image does not exist, the update operation will return 0.
/// </remarks>
public bool Update(UserImage image)
{
return _col.Update(image);
@@ -70,6 +131,7 @@ namespace skydiveLogs_api.Infrastructure
#region Private Fields
private readonly ILiteCollection<UserImage> _col;
private readonly IDataProvider _dataProvider;
#endregion Private Fields
@@ -1,4 +1,4 @@
using LiteDB;
using LiteDB;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces;
@@ -11,6 +11,10 @@ namespace skydiveLogs_api.Infrastructure
{
#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)
{
_dataProvider = dataProvider;
@@ -21,6 +25,11 @@ namespace skydiveLogs_api.Infrastructure
#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)
{
int result;
@@ -38,26 +47,50 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
/// <summary>
/// Retrieves all users from the database
/// </summary>
/// <returns>A collection of all user instances</returns>
public IEnumerable<User> GetAll()
{
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)
{
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)
{
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()
{
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)
{
throw new NotImplementedException();
@@ -1,10 +1,10 @@
using AutoMapper;
using System.Collections.Generic;
using AutoMapper;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using skydiveLogs_api.DataContract;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainBusiness.Interfaces;
using System.Collections.Generic;
namespace skydiveLogs_api.Controllers
{
@@ -23,7 +23,10 @@ namespace skydiveLogs_api.Controllers
#region Public Methods
// DELETE: api/ApiWithActions/5
/// <summary>
/// Deletes an aircraft by its ID.
/// </summary>
/// <param name="id">The aircraft ID to delete.</param>
[HttpDelete("{id}")]
[EnableCors]
public void Delete(int id)
@@ -31,7 +34,10 @@ namespace skydiveLogs_api.Controllers
_aircraftService.DeleteAircraftById(id);
}
// GET: api/Aircraft
/// <summary>
/// Retrieves a list of all aircraft.
/// </summary>
/// <returns>A collection of AircraftResp objects containing all aircraft data.</returns>
[HttpGet]
[EnableCors]
public IEnumerable<AircraftResp> Get()
@@ -40,7 +46,11 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<IEnumerable<AircraftResp>>(result);
}
// GET: api/Aircraft/5
/// <summary>
/// Retrieves an aircraft by its ID.
/// </summary>
/// <param name="id">The aircraft ID to retrieve.</param>
/// <returns>An AircraftResp object containing the aircraft details.</returns>
[HttpGet("{id}")]
[EnableCors]
public AircraftResp Get(int id)
@@ -49,6 +59,10 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<AircraftResp>(result);
}
/// <summary>
/// Retrieves a simplified list of all aircraft.
/// </summary>
/// <returns>A collection of AircraftSimpleResp objects containing simplified aircraft data.</returns>
[HttpGet("GetSimple")]
[EnableCors]
public IEnumerable<AircraftSimpleResp> GetSimple()
@@ -57,7 +71,10 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<IEnumerable<AircraftSimpleResp>>(result);
}
// POST: api/Aircraft
/// <summary>
/// Adds a new aircraft to the system.
/// </summary>
/// <param name="value">AircraftReq object containing the new aircraft data.</param>
[HttpPost]
[EnableCors]
public void Post([FromBody] AircraftReq value)
@@ -65,7 +82,11 @@ namespace skydiveLogs_api.Controllers
_aircraftService.AddNewAircraft(_mapper.Map<Aircraft>(value));
}
// PUT: api/Aircraft/5
/// <summary>
/// Updates an existing aircraft.
/// </summary>
/// <param name="id">The aircraft ID to update.</param>
/// <param name="value">AircraftReq object containing the updated aircraft data.</param>
[HttpPut("{id}")]
[EnableCors]
public void Put(int id, [FromBody] AircraftReq value)
@@ -1,10 +1,10 @@
using AutoMapper;
using System.Collections.Generic;
using AutoMapper;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using skydiveLogs_api.DataContract;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainBusiness.Interfaces;
using System.Collections.Generic;
namespace skydiveLogs_api.Controllers
{
@@ -23,7 +23,11 @@ namespace skydiveLogs_api.Controllers
#region Public Methods
// PUT: api/DropZone/AddToFavorite/5
/// <summary>
/// Adds a drop zone to the user's favorites.
/// </summary>
/// <param name="id">The drop zone ID to add to favorites.</param>
/// <returns>True if successful, false otherwise.</returns>
[HttpPut("AddToFavorite/{id}")]
[EnableCors]
public bool AddToFavorite(int id)
@@ -31,7 +35,10 @@ namespace skydiveLogs_api.Controllers
return _dropZoneService.AddToFavorite(id);
}
// DELETE: api/ApiWithActions
/// <summary>
/// Deletes a drop zone by its ID.
/// </summary>
/// <param name="id">The drop zone ID to delete.</param>
[HttpDelete("{id}")]
[EnableCors]
public void Delete(int id)
@@ -39,7 +46,10 @@ namespace skydiveLogs_api.Controllers
_dropZoneService.DeleteDzById(id);
}
// GET: api/DropZone
/// <summary>
/// Retrieves a list of all drop zones.
/// </summary>
/// <returns>A collection of DropZoneResp objects containing all drop zones.</returns>
[HttpGet]
[EnableCors]
public IEnumerable<DropZoneResp> Get()
@@ -49,7 +59,11 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<IEnumerable<DropZoneResp>>(result);
}
// GET: api/DropZone/5
/// <summary>
/// Retrieves a drop zone by its ID.
/// </summary>
/// <param name="id">The drop zone ID to retrieve.</param>
/// <returns>A DropZoneResp object containing the drop zone details.</returns>
[HttpGet("{id}")]
[EnableCors]
public DropZoneResp Get(int id)
@@ -59,6 +73,10 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<DropZoneResp>(result);
}
/// <summary>
/// Retrieves a simplified list of all drop zones.
/// </summary>
/// <returns>A collection of DropZoneSimpleResp objects containing simplified drop zone data.</returns>
[HttpGet("GetSimple")]
[EnableCors]
public IEnumerable<DropZoneSimpleResp> GetSimple()
@@ -68,7 +86,10 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<IEnumerable<DropZoneSimpleResp>>(result);
}
// POST: api/DropZone
/// <summary>
/// Adds a new drop zone to the system.
/// </summary>
/// <param name="value">DropZoneReq object containing the new drop zone data.</param>
[HttpPost]
[EnableCors]
public void Post([FromBody] DropZoneReq value)
@@ -76,7 +97,12 @@ namespace skydiveLogs_api.Controllers
_dropZoneService.AddNewDz(_mapper.Map<DropZone>(value));
}
// PUT: api/DropZone/5
/// <summary>
/// Updates an existing drop zone.
/// </summary>
/// <param name="id">The drop zone ID to update.</param>
/// <param name="value">DropZoneReq object containing the updated drop zone data.</param>
/// <returns>True if successful, false otherwise.</returns>
[HttpPut("{id}")]
[EnableCors]
public bool Put(int id, [FromBody] DropZoneReq value)
@@ -84,7 +110,11 @@ namespace skydiveLogs_api.Controllers
return _dropZoneService.UpdateDz(id, _mapper.Map<DropZone>(value));
}
// PUT: api/DropZone/RemoveToFavorite/15
/// <summary>
/// Removes a drop zone from the user's favorites.
/// </summary>
/// <param name="id">The drop zone ID to remove from favorites.</param>
/// <returns>True if successful, false otherwise.</returns>
[HttpPut("RemoveToFavorite/{id}")]
[EnableCors]
public bool RemoveToFavorite(int id)
@@ -1,10 +1,10 @@
using AutoMapper;
using System.Collections.Generic;
using AutoMapper;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using skydiveLogs_api.DataContract;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainBusiness.Interfaces;
using System.Collections.Generic;
namespace skydiveLogs_api.Controllers
{
@@ -23,7 +23,10 @@ namespace skydiveLogs_api.Controllers
#region Public Methods
// DELETE: api/ApiWithActions/5
/// <summary>
/// Deletes a gear item by its ID.
/// </summary>
/// <param name="id">The gear ID to delete.</param>
[HttpDelete("{id}")]
[EnableCors]
public void Delete(int id)
@@ -31,17 +34,23 @@ namespace skydiveLogs_api.Controllers
_gearService.DeleteGearById(id);
}
// GET: api/Gear
/// <summary>
/// Retrieves a list of all gear items.
/// </summary>
/// <returns>A collection of GearResp objects containing all gear data.</returns>
[HttpGet]
[EnableCors]
public IEnumerable<GearResp> Get()
{
//var result = _gearService.GetAllGears(ConnectedUser);
var result = _gearService.GetAllGears();
return _mapper.Map<IEnumerable<GearResp>>(result);
}
// GET: api/Gear/5
/// <summary>
/// Retrieves a gear item by its ID.
/// </summary>
/// <param name="id">The gear ID to retrieve.</param>
/// <returns>A GearResp object containing the gear details.</returns>
[HttpGet("{id}")]
[EnableCors]
public GearResp Get(int id)
@@ -50,7 +59,10 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<GearResp>(result);
}
// POST: api/Gear
/// <summary>
/// Adds a new gear item to the system.
/// </summary>
/// <param name="value">GearReq object containing the new gear data.</param>
[HttpPost]
[EnableCors]
public void Post([FromBody] GearReq value)
@@ -58,7 +70,11 @@ namespace skydiveLogs_api.Controllers
_gearService.AddNewGear(_mapper.Map<Gear>(value));
}
// PUT: api/Gear/5
/// <summary>
/// Updates an existing gear item.
/// </summary>
/// <param name="id">The gear ID to update.</param>
/// <param name="value">GearReq object containing the updated gear data.</param>
[HttpPut("{id}")]
[EnableCors]
public void Put(int id, [FromBody] GearReq value)
@@ -1,10 +1,10 @@
using AutoMapper;
using System.Collections.Generic;
using AutoMapper;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using skydiveLogs_api.DataContract;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainBusiness.Interfaces;
using System.Collections.Generic;
namespace skydiveLogs_api.Controllers
{
@@ -23,7 +23,10 @@ namespace skydiveLogs_api.Controllers
#region Public Methods
// DELETE: api/Image/5
/// <summary>
/// Deletes an image by its ID.
/// </summary>
/// <param name="id">The image ID to delete.</param>
[HttpDelete("{id}")]
[EnableCors]
public void Delete(int id)
@@ -31,7 +34,10 @@ namespace skydiveLogs_api.Controllers
_imageService.DeleteImageById(id);
}
// GET: api/Image
/// <summary>
/// Retrieves a list of all images.
/// </summary>
/// <returns>A collection of ImageResp objects containing all images.</returns>
[HttpGet]
[EnableCors]
public IEnumerable<ImageResp> Get()
@@ -40,7 +46,11 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<IEnumerable<ImageResp>>(result);
}
// GET: api/Image/5
/// <summary>
/// Retrieves an image by its ID.
/// </summary>
/// <param name="id">The image ID to retrieve.</param>
/// <returns>An ImageResp object containing the image details.</returns>
[HttpGet("{id}")]
[EnableCors]
public ImageResp Get(int id)
@@ -49,7 +59,10 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<ImageResp>(result);
}
// POST: api/Image
/// <summary>
/// Adds a new image to the system.
/// </summary>
/// <param name="value">ImageReq object containing the new image data.</param>
[HttpPost]
[EnableCors]
public void Post([FromBody] ImageReq value)
@@ -57,7 +70,11 @@ namespace skydiveLogs_api.Controllers
_imageService.AddNewImage(_mapper.Map<UserImage>(value));
}
// PUT: api/Image/5
/// <summary>
/// Updates an existing image.
/// </summary>
/// <param name="id">The image ID to update.</param>
/// <param name="value">ImageReq object containing the updated image data.</param>
[HttpPut("{id}")]
[EnableCors]
public void Put(int id, [FromBody] ImageReq value)
@@ -24,7 +24,10 @@ namespace skydiveLogs_api.Controllers
#region Public Methods
// DELETE: api/Jump/5
/// <summary>
/// Deletes a jump by its ID.
/// </summary>
/// <param name="id">The jump ID to delete.</param>
[HttpDelete("{id}")]
[EnableCors]
public void Delete(int id)
@@ -32,7 +35,10 @@ namespace skydiveLogs_api.Controllers
_jumpService.DeleteJumpById(id);
}
// GET: api/Jump
/// <summary>
/// Retrieves a list of all jumps.
/// </summary>
/// <returns>A JumpListResp containing all jumps and their count.</returns>
[HttpGet]
[EnableCors]
public JumpListResp Get()
@@ -47,7 +53,12 @@ namespace skydiveLogs_api.Controllers
return result;
}
// GET: api/Jump/5/10
/// <summary>
/// Retrieves a page of jumps with pagination.
/// </summary>
/// <param name="beginJumpIndex">The starting index for pagination.</param>
/// <param name="endJumpIndex">The ending index for pagination.</param>
/// <returns>A JumpListResp containing the requested page and total count.</returns>
[HttpGet("{beginJumpIndex}/{endJumpIndex}")]
[EnableCors]
public JumpListResp Get(int beginJumpIndex, int endJumpIndex)
@@ -63,7 +74,11 @@ namespace skydiveLogs_api.Controllers
return result;
}
// GET: api/Jump/5
/// <summary>
/// Retrieves a jump by its ID.
/// </summary>
/// <param name="id">The jump ID to retrieve.</param>
/// <returns>A JumpResp containing the jump details.</returns>
[HttpGet("{id}")]
[EnableCors]
public JumpResp Get(int id)
@@ -72,7 +87,10 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<JumpResp>(result);
}
// POST: api/Jump
/// <summary>
/// Adds a new jump to the system.
/// </summary>
/// <param name="value">JumpReq object containing the new jump data.</param>
[HttpPost]
[EnableCors]
public void Post([FromBody] JumpReq value)
@@ -84,7 +102,11 @@ namespace skydiveLogs_api.Controllers
_mapper.Map<Jump>(value));
}
// PUT: api/Jump/5
/// <summary>
/// Updates an existing jump.
/// </summary>
/// <param name="id">The jump ID to update.</param>
/// <param name="value">JumpReq object containing the new jump data.</param>
[HttpPut("{id}")]
[EnableCors]
public void Put(int id, [FromBody] JumpReq value)
@@ -1,10 +1,10 @@
using AutoMapper;
using System.Collections.Generic;
using AutoMapper;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using skydiveLogs_api.DataContract;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainBusiness.Interfaces;
using System.Collections.Generic;
namespace skydiveLogs_api.Controllers
{
@@ -23,7 +23,10 @@ namespace skydiveLogs_api.Controllers
#region Public Methods
// DELETE: api/ApiWithActions/5
/// <summary>
/// Deletes a jump type by its ID.
/// </summary>
/// <param name="id">The jump type ID to delete.</param>
[HttpDelete("{id}")]
[EnableCors]
public void Delete(int id)
@@ -31,7 +34,10 @@ namespace skydiveLogs_api.Controllers
_jumpTypeService.DeleteJumpTypeById(id);
}
// GET: api/JumpType
/// <summary>
/// Retrieves a list of all jump types.
/// </summary>
/// <returns>A collection of JumpTypeResp objects containing all jump types.</returns>
[HttpGet]
[EnableCors]
public IEnumerable<JumpTypeResp> Get()
@@ -40,7 +46,10 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<IEnumerable<JumpTypeResp>>(result);
}
// GET: api/JumpType/tunnel
/// <summary>
/// Retrieves jump types used for tunnel operations.
/// </summary>
/// <returns>A collection of JumpTypeResp objects containing tunnel jump types.</returns>
[HttpGet("tunnel")]
[EnableCors]
public IEnumerable<JumpTypeResp> GetForTunnel()
@@ -49,7 +58,11 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<IEnumerable<JumpTypeResp>>(result);
}
// GET: api/JumpType/5
/// <summary>
/// Retrieves a jump type by its ID.
/// </summary>
/// <param name="id">The jump type ID to retrieve.</param>
/// <returns>A JumpTypeResp object containing the jump type details.</returns>
[HttpGet("{id}")]
[EnableCors]
public JumpTypeResp Get(int id)
@@ -58,7 +71,10 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<JumpTypeResp>(result);
}
// POST: api/JumpType
/// <summary>
/// Adds a new jump type to the system.
/// </summary>
/// <param name="value">JumpTypeReq object containing the new jump type data.</param>
[HttpPost]
[EnableCors]
public void Post([FromBody] JumpTypeReq value)
@@ -66,7 +82,11 @@ namespace skydiveLogs_api.Controllers
_jumpTypeService.AddNewJumpType(_mapper.Map<JumpType>(value));
}
// PUT: api/JumpType/5
/// <summary>
/// Updates an existing jump type.
/// </summary>
/// <param name="id">The jump type ID to update.</param>
/// <param name="value">JumpTypeReq object containing the updated jump type data.</param>
[HttpPut("{id}")]
[EnableCors]
public void Put(int id, [FromBody] JumpTypeReq value)
@@ -22,6 +22,10 @@ namespace skydiveLogs_api.Controllers
#region Public Methods
/// <summary>
/// Retrieves statistics grouped by aircraft.
/// </summary>
/// <returns>A collection of StatisticResp objects containing aircraft statistics.</returns>
[HttpGet("ByAircraft")]
[EnableCors]
public IEnumerable<StatisticResp> ByAircraft()
@@ -31,6 +35,10 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
/// <summary>
/// Retrieves statistics grouped by drop zone.
/// </summary>
/// <returns>A collection of StatisticResp objects containing drop zone statistics.</returns>
[HttpGet("ByDz")]
[EnableCors]
public IEnumerable<StatisticResp> ByDz()
@@ -40,6 +48,10 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
/// <summary>
/// Retrieves statistics grouped by gear.
/// </summary>
/// <returns>A collection of StatisticResp objects containing gear statistics.</returns>
[HttpGet("ByGear")]
[EnableCors]
public IEnumerable<StatisticResp> ByGear()
@@ -49,6 +61,10 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
/// <summary>
/// Retrieves statistics grouped by jump type.
/// </summary>
/// <returns>A collection of StatisticResp objects containing jump type statistics.</returns>
[HttpGet("ByJumpType")]
[EnableCors]
public IEnumerable<StatisticResp> ByJumpType()
@@ -58,6 +74,10 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
/// <summary>
/// Retrieves statistics grouped by year.
/// </summary>
/// <returns>A collection of StatisticResp objects containing year statistics.</returns>
[HttpGet("ByYear")]
[EnableCors]
public IEnumerable<StatisticResp> ByYear()
@@ -67,6 +87,10 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
/// <summary>
/// Retrieves statistics for the last month grouped by drop zone and jump type.
/// </summary>
/// <returns>A StatisticForLastMonthResp object containing last month statistics.</returns>
[HttpGet("ForLastMonth")]
[EnableCors]
public StatisticForLastMonthResp ForLastMonth()
@@ -81,6 +105,10 @@ namespace skydiveLogs_api.Controllers
return result;
}
/// <summary>
/// Retrieves statistics for the last year grouped by drop zone and jump type.
/// </summary>
/// <returns>A StatisticForLastYearResp object containing last year statistics.</returns>
[HttpGet("ForLastYear")]
[EnableCors]
public StatisticForLastYearResp ForLastYear()
@@ -95,6 +123,10 @@ namespace skydiveLogs_api.Controllers
return result;
}
/// <summary>
/// Retrieves statistics by year grouped with jump type for chart visualization.
/// </summary>
/// <returns>A collection of StatisticForChartResp objects containing yearly jump type statistics.</returns>
[HttpGet("ByYearByJumpType")]
[EnableCors]
public IEnumerable<StatisticForChartResp> ByYearByJumpType()
@@ -104,6 +136,9 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<IEnumerable<StatisticForChartResp>>(result);
}
/// <summary>
/// Resets all statistics to their initial state.
/// </summary>
[HttpGet("Reset")]
[EnableCors]
public void Reset()
@@ -111,6 +146,10 @@ namespace skydiveLogs_api.Controllers
_statsService.Reset();
}
/// <summary>
/// Retrieves a simple summary of all statistics.
/// </summary>
/// <returns>A SimpleSummaryResp object containing the simple summary statistics.</returns>
[HttpGet("Simple")]
[EnableCors]
public SimpleSummaryResp Simple()
@@ -1,9 +1,9 @@
using AutoMapper;
using System.Collections.Generic;
using AutoMapper;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using skydiveLogs_api.DataContract;
using skydiveLogs_api.DomainBusiness.Interfaces;
using System.Collections.Generic;
namespace skydiveLogs_api.Controllers
{
@@ -22,7 +22,10 @@ namespace skydiveLogs_api.Controllers
#region Public Methods
// GET: api/Tunnel
/// <summary>
/// Retrieves a list of all tunnels.
/// </summary>
/// <returns>A collection of TunnelResp objects containing all tunnels.</returns>
[HttpGet]
[EnableCors]
public IEnumerable<TunnelResp> Get()
@@ -31,7 +34,11 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<IEnumerable<TunnelResp>>(result);
}
// GET: api/Tunnel/5
/// <summary>
/// Retrieves a tunnel by its ID.
/// </summary>
/// <param name="id">The tunnel ID to retrieve.</param>
/// <returns>A TunnelResp object containing the tunnel details.</returns>
[HttpGet("{id}")]
[EnableCors]
public TunnelResp Get(int id)
@@ -1,10 +1,10 @@
using AutoMapper;
using System.Collections.Generic;
using AutoMapper;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using skydiveLogs_api.DataContract;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainBusiness.Interfaces;
using System.Collections.Generic;
namespace skydiveLogs_api.Controllers
{
@@ -23,7 +23,10 @@ namespace skydiveLogs_api.Controllers
#region Public Methods
// GET: api/TunnelFlight
/// <summary>
/// Retrieves a list of all tunnel flights.
/// </summary>
/// <returns>A collection of TunnelFlightResp objects containing all tunnel flights.</returns>
[HttpGet]
[EnableCors]
public IEnumerable<TunnelFlightResp> Get()
@@ -32,7 +35,11 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<IEnumerable<TunnelFlightResp>>(result);
}
// GET: api/TunnelFlight/5
/// <summary>
/// Retrieves a tunnel flight by its ID.
/// </summary>
/// <param name="id">The tunnel flight ID to retrieve.</param>
/// <returns>A TunnelFlightResp object containing the tunnel flight details.</returns>
[HttpGet("{id}")]
[EnableCors]
public TunnelFlightResp Get(int id)
@@ -41,7 +48,12 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<TunnelFlightResp>(result);
}
// GET: api/TunnelFlight/20230101/20230701
/// <summary>
/// Retrieves tunnel flights filtered by date range.
/// </summary>
/// <param name="beginDate">The start date for filtering.</param>
/// <param name="endDate">The end date for filtering.</param>
/// <returns>A collection of TunnelFlightResp objects filtered by the specified date range.</returns>
[HttpGet("{beginDate}/{endDate}")]
[EnableCors]
public IEnumerable<TunnelFlightResp> Get(string beginDate, string endDate)
@@ -50,7 +62,12 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<IEnumerable<TunnelFlightResp>>(result);
}
// GET: api/TunnelFlight/month/20230101/20230701
/// <summary>
/// Retrieves tunnel flights grouped by month within a date range.
/// </summary>
/// <param name="beginDate">The start date for grouping.</param>
/// <param name="endDate">The end date for grouping.</param>
/// <returns>A collection of StatisticForChartResp objects grouped by month.</returns>
[HttpGet("month/{beginDate}/{endDate}")]
[EnableCors]
public IEnumerable<StatisticForChartResp> GetGroupByMonth(string beginDate, string endDate)
@@ -59,7 +76,10 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<IEnumerable<StatisticForChartResp>>(result);
}
// POST: api/Tunnel
/// <summary>
/// Adds a new tunnel flight to the system.
/// </summary>
/// <param name="value">TunnelFlightReq object containing the new tunnel flight data.</param>
[HttpPost]
[EnableCors]
public void Post([FromBody] TunnelFlightReq value)
@@ -69,7 +89,11 @@ namespace skydiveLogs_api.Controllers
_mapper.Map<TunnelFlight>(value));
}
// PUT: api/TunnelFlight/5
/// <summary>
/// Updates an existing tunnel flight.
/// </summary>
/// <param name="id">The tunnel flight ID to update.</param>
/// <param name="value">TunnelFlightReq object containing the updated tunnel flight data.</param>
[HttpPut("{id}")]
[EnableCors]
public void Put(int id, [FromBody] TunnelFlightReq value)
@@ -77,7 +101,10 @@ namespace skydiveLogs_api.Controllers
_tunnelFlightService.UpdateTunnelFlight(id, _mapper.Map<TunnelFlight>(value));
}
// DELETE: api/TunnelFlight/5
/// <summary>
/// Deletes a tunnel flight by its ID.
/// </summary>
/// <param name="id">The tunnel flight ID to delete.</param>
[HttpDelete("{id}")]
[EnableCors]
public void Delete(int id)
@@ -1,4 +1,8 @@
using AutoMapper;
using System;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Text;
using AutoMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
@@ -8,10 +12,6 @@ using skydiveLogs_api.DataContract;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainBusiness.Interfaces;
using skydiveLogs_api.Settings;
using System;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Text;
namespace skydiveLogs_api.Controllers
{
@@ -34,7 +34,10 @@ namespace skydiveLogs_api.Controllers
#region Public Methods
// GET: api/User/AlwayLogin
/// <summary>
/// Always login endpoint for testing authentication status.
/// </summary>
/// <returns>An Ok result indicating successful authentication.</returns>
[HttpGet("AlwaysLogin")]
[EnableCors]
public IActionResult AlwaysLogin()
@@ -42,7 +45,11 @@ namespace skydiveLogs_api.Controllers
return Ok();
}
// POST: api/User/Authenticate
/// <summary>
/// Authenticates a user with login and password.
/// </summary>
/// <param name="value">UserReq containing login and password.</param>
/// <returns>UserResp with token if successful, BadRequest if failed.</returns>
[AllowAnonymous]
[HttpPost("Authenticate")]
[EnableCors]
@@ -67,7 +74,11 @@ namespace skydiveLogs_api.Controllers
return result;
}
// POST: api/User
/// <summary>
/// Creates a new user and returns JWT token.
/// </summary>
/// <param name="userToAdd">UserReq object containing new user data.</param>
/// <returns>UserResp with token if successful, BadRequest on error.</returns>
[AllowAnonymous]
[HttpPost]
[EnableCors]
@@ -25,5 +25,7 @@ namespace skydiveLogs_api.DataContract
public DateTime JumpDate { get; set; }
public bool IsSpecial { get; set; }
public string Equipment { get; set; }
}
}
@@ -7,18 +7,29 @@ namespace skydiveLogs_api.DataContract
#region Public Properties
public int AircraftId { get; set; }
public int DeployAltitude { get; set; }
public int DropZoneId { get; set; }
public int ExitAltitude { get; set; }
public int GearId { get; set; }
public int Id { get; set; }
public bool IsSpecial { get; set; }
public DateTime JumpDate { get; set; }
public int JumpTypeId { get; set; }
public string Notes { get; set; }
public bool WithCutaway { get; set; }
public string Equipment { get; set; }
#endregion Public Properties
}
}
@@ -0,0 +1,91 @@
<form (ngSubmit)="updateGear()">
<p>
<mat-form-field>
<mat-label>{{ "GearInfos_Name" | translate }}</mat-label>
<input
type="text"
matInput
name="name"
[(ngModel)]="gear.name"
name="name"
type="text"
/>
</mat-form-field>
</p>
<p>
<mat-form-field>
<mat-label>{{ "GearInfos_Manufacturer" | translate }}</mat-label>
<input
type="text"
matInput
name="manufacturer"
[(ngModel)]="gear.manufacturer"
name="manufacturer"
/>
</mat-form-field>
</p>
<p>
<mat-form-field>
<mat-label>{{ "GearInfos_MinSize" | translate }}Min size</mat-label>
<input
type="text"
matInput
name="minSize"
[(ngModel)]="gear.minSize"
name="minSize"
/>
</mat-form-field>
</p>
<p>
<mat-form-field>
<mat-label>{{ "GearInfos_MaxSize" | translate }}</mat-label>
<input
type="text"
matInput
name="maxSize"
[(ngModel)]="gear.maxSize"
name="maxSize"
/>
</mat-form-field>
</p>
<p>
<mat-form-field>
<mat-label>{{ "GearInfos_AAD" | translate }}</mat-label>
<input
type="text"
matInput
name="aad"
[(ngModel)]="gear.aad"
name="aad"
/>
</mat-form-field>
</p>
<p>
<mat-form-field>
<mat-label>{{ "GearInfos_MainCanopy" | translate }}</mat-label>
<input
type="text"
matInput
name="mainCanopy"
[(ngModel)]="gear.mainCanopy"
name="mainCanopy"
/>
</mat-form-field>
</p>
<p>
<mat-form-field>
<mat-label>{{ "GearInfos_ReserveCanopy" | translate }}</mat-label>
<input
type="text"
matInput
name="reserveCanopy"
[(ngModel)]="gear.reserveCanopy"
name="reserveCanopy"
/>
</mat-form-field>
</p>
<br />
@if (editMode) {
<button mat-raised-button color="accent">Update</button>
}
</form>
@@ -0,0 +1,62 @@
import { Component, Inject, OnInit } from "@angular/core";
import { MAT_DIALOG_DATA } from "@angular/material/dialog";
import { TranslateModule } from "@ngx-translate/core";
import { MatCheckboxModule } from "@angular/material/checkbox";
import { MatFormFieldModule } from "@angular/material/form-field";
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
import { MatInputModule } from "@angular/material/input";
import { MatButtonModule } from "@angular/material/button";
import { AddAction } from "../../models/add-action.enum";
import { GearResp } from "../../models/gear";
import { GearService } from "../../services/gear.service";
import { ServiceComm } from "../../services/service-comm.service";
@Component({
selector: "app-gear-infos",
templateUrl: "./gear-infos.component.html",
styleUrls: ["./gear-infos.component.css"],
imports: [
TranslateModule,
FormsModule,
MatCheckboxModule,
MatFormFieldModule,
ReactiveFormsModule,
MatInputModule,
MatButtonModule,
],
})
export class GearInfosComponent implements OnInit {
public editMode: boolean;
public gear: GearResp;
constructor(
@Inject(MAT_DIALOG_DATA) public data: any,
private serviceGear: GearService,
private serviceComm: ServiceComm,
) {
this.gear = new GearResp(data.gear);
this.editMode = data.editMode;
}
ngOnInit(): void {}
public updateGear() {
this.serviceGear
.updateGear(
this.gear.id,
this.gear.name,
this.gear.manufacturer,
this.gear.minSize,
this.gear.maxSize,
this.gear.aad,
this.gear.mainCanopy,
this.gear.reserveCanopy,
)
.subscribe(() => {
this.serviceComm.refreshData(AddAction.Gear);
});
}
}
@@ -7,6 +7,7 @@
[(ngModel)]="jump.isSpecial"
name="isSpecial"
labelPosition="before"
[disabled]="!editMode"
>Special jump</mat-checkbox
>
</p>
@@ -15,6 +16,7 @@
[(ngModel)]="jump.withCutaway"
name="withCutaway"
labelPosition="before"
[disabled]="!editMode"
>Cutaway</mat-checkbox
>
</p>
@@ -26,11 +28,22 @@
[(ngModel)]="jump.notes"
name="comments"
type="text"
[disabled]="!editMode"
></textarea>
</mat-form-field>
<br />
<p>
<mat-form-field>
<mat-label>{{ "NewJump_Equipment" | translate }}</mat-label>
<mat-select [(value)]="jump.equipment" [disabled]="!editMode">
@for (equipment of listOfEquipment; track equipment) {
<mat-option [value]="equipment.value">{{
equipment.viewValue
}}</mat-option>
}
</mat-select>
</mat-form-field>
@if (editMode) {
<button mat-raised-button color="accent">Update</button>
}
</p>
</form>
@@ -7,6 +7,7 @@ import { MatFormFieldModule } from "@angular/material/form-field";
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
import { MatInputModule } from "@angular/material/input";
import { MatButtonModule } from "@angular/material/button";
import { MatSelectModule } from "@angular/material/select";
import { AddAction } from "../../models/add-action.enum";
import { JumpResp } from "../../models/jump";
@@ -14,6 +15,11 @@ import { JumpResp } from "../../models/jump";
import { JumpService } from "../../services/jump.service";
import { ServiceComm } from "../../services/service-comm.service";
interface Equipment {
value: string;
viewValue: string;
}
@Component({
selector: "app-jump-infos",
templateUrl: "./jump-infos.component.html",
@@ -26,11 +32,21 @@ import { ServiceComm } from "../../services/service-comm.service";
ReactiveFormsModule,
MatInputModule,
MatButtonModule,
MatSelectModule,
],
})
export class JumpInfosComponent implements OnInit {
public editMode: boolean;
public jump: JumpResp;
public selectedEquipment: string;
public listOfEquipment: Array<Equipment> = [
{ value: "", viewValue: "<None>" },
{ value: "Freak 6", viewValue: "Freak 6" },
{ value: "ATC 4", viewValue: "ATC 4" },
{ value: "ATC 2", viewValue: "ATC 2" },
{ value: "Havok", viewValue: "Havok" },
{ value: "Hawk", viewValue: "Hawk" },
];
constructor(
@Inject(MAT_DIALOG_DATA) public data: any,
@@ -38,6 +54,7 @@ export class JumpInfosComponent implements OnInit {
private serviceComm: ServiceComm,
) {
this.jump = new JumpResp(data.jump);
this.selectedEquipment = this.jump.equipment;
this.editMode = data.editMode;
}
@@ -50,6 +67,7 @@ export class JumpInfosComponent implements OnInit {
this.jump.isSpecial,
this.jump.withCutaway,
this.jump.notes,
this.jump.equipment,
)
.subscribe(() => {
this.serviceComm.refreshData(AddAction.Jump);
@@ -71,6 +71,26 @@
{{ element.reserveCanopy }}
</td>
</ng-container>
<ng-container matColumnDef="actions">
<th
mat-header-cell
*matHeaderCellDef
style="min-width: 80px; text-wrap: nowrap"
></th>
<td
mat-cell
*matCellDef="let element"
style="text-align: left; text-wrap: nowrap"
>
<mat-icon
aria-hidden="false"
aria-label="Update this gear"
style="cursor: pointer; margin-left: 10px"
(click)="openDialog(element, true)"
svgIcon="edit"
></mat-icon>
</td>
</ng-container>
<tr
mat-header-row
*matHeaderRowDef="displayedColumns; sticky: true"
@@ -6,12 +6,14 @@ import { TranslateModule, TranslateService } from "@ngx-translate/core";
import { MatProgressSpinnerModule } from "@angular/material/progress-spinner";
import { MatButtonModule } from "@angular/material/button";
import { MatIconModule } from "@angular/material/icon";
import { GearService } from "../../services/gear.service";
import { ServiceComm } from "../../services/service-comm.service";
import { GearResp } from "../../models/gear";
import { AddAction } from "../../models/add-action.enum";
import { NewGearComponent } from "../new-gear/new-gear.component";
import { GearInfosComponent } from "../gear-infos/gear-infos.component";
@Component({
selector: "app-list-of-gears",
@@ -23,6 +25,7 @@ import { NewGearComponent } from "../new-gear/new-gear.component";
MatProgressSpinnerModule,
MatTableModule,
MatButtonModule,
MatIconModule,
],
})
export class ListOfGearsComponent implements OnInit {
@@ -33,6 +36,7 @@ export class ListOfGearsComponent implements OnInit {
"aad",
"mainCanopy",
"reserveCanopy",
"actions",
];
public dataSourceTable: MatTableDataSource<GearResp>;
public resultsLength = 0;
@@ -80,6 +84,14 @@ export class ListOfGearsComponent implements OnInit {
});
}
openDialog(item: GearResp, editMode: boolean) {
this.dialog.open(GearInfosComponent, {
data: { gear: item, editMode: editMode },
maxHeight: "400px",
minWidth: "350px",
});
}
private updateTitle() {
this.translateService.get("ListGears_Title").subscribe((data) => {
this.serviceComm.updatedComponentTitle(data);
@@ -105,7 +105,7 @@ export class ListOfJumpsComponent implements OnInit {
openDialog(item: Jump, editMode: boolean) {
this.dialog.open(JumpInfosComponent, {
data: { jump: item, editMode: editMode },
maxHeight: "400px",
maxHeight: "450px",
minWidth: "350px",
});
}
@@ -33,7 +33,7 @@
<mat-nav-list>
@for (stat of stats; track stat) {
<mat-list-item matListItemLine>
<label>{{ stat.id }} : {{ stat.values }}</label>
<label>{{ stat.label }} : {{ stat.hoursAndMinutes.hours }}h {{ stat.hoursAndMinutes.minutes }}m</label>
</mat-list-item>
}
</mat-nav-list>
@@ -59,7 +59,13 @@ export class ListOfTunnelFlightsComponent implements OnInit {
"flightDate",
"actions",
];
public stats: Array<{ id: String | Number; values: String | Number }> = [];
public stats: Array<{
label: String;
hoursAndMinutes: {
hours: number;
minutes: number;
};
}> = [];
constructor(
private serviceComm: ServiceComm,
@@ -92,6 +98,14 @@ export class ListOfTunnelFlightsComponent implements OnInit {
this.getDataForTable();
}
public delete(item: TunnelFlight) {
let data: Array<TunnelFlight> = this.dataSourceTable.data;
data = data.filter((d) => d.id !== item.id);
this.dataSourceTable.data = data;
this.serviceTunnelFlight.deleteTunnelFlight(item);
}
private chartConfig() {
this.barChartType = "bar";
this.barChartOptions = {
@@ -190,15 +204,25 @@ export class ListOfTunnelFlightsComponent implements OnInit {
),
),
map((arr) => ({
id: arr[0],
label: arr[0],
values: arr
.slice(1)
.reduce((a, b) => Number(a) + Number(b), 0),
hoursAndMinutes: {},
})),
)
.subscribe((p) => {
console.log(p);
this.stats.push(p);
let newStat: {
label: String;
hoursAndMinutes: {
hours: number;
minutes: number;
};
} = {
label: p.label.toString(),
hoursAndMinutes: this.toHoursAndMinutes(+p.values),
};
this.stats.push(newStat);
});
}
@@ -285,11 +309,13 @@ export class ListOfTunnelFlightsComponent implements OnInit {
return beginDate;
}
public delete(item: TunnelFlight) {
let data: Array<TunnelFlight> = this.dataSourceTable.data;
data = data.filter((d) => d.id !== item.id);
private toHoursAndMinutes(totalMinutes: number): {
hours: number;
minutes: number;
} {
const hours = Math.floor(totalMinutes / 60);
const minutes = totalMinutes % 60;
this.dataSourceTable.data = data;
this.serviceTunnelFlight.deleteTunnelFlight(item);
return { hours, minutes };
}
}
@@ -30,7 +30,7 @@
</mat-option>
</mat-select>
</mat-card-title>
<mat-card-subtitle style="font-size: 12px">
<mat-card-subtitle style="font-size: 12px; text-align: center;">
{{ "App_Footer" | translate }}{{ version }} - &#64;Séb
</mat-card-subtitle>
</mat-card-header>
@@ -152,6 +152,16 @@
</button>
}
</mat-form-field>
<mat-form-field>
<mat-label>{{ "NewJump_Equipment" | translate }}</mat-label>
<mat-select [(value)]="selectedEquipment">
@for (equipment of listOfEquipment; track equipment) {
<mat-option [value]="equipment.value">{{
equipment.viewValue
}}</mat-option>
}
</mat-select>
</mat-form-field>
<mat-checkbox [(ngModel)]="withCutaway" name="withCutaway">{{
"NewJump_Cutaway" | translate
}}</mat-checkbox>
@@ -18,6 +18,7 @@ import { MatProgressSpinnerModule } from "@angular/material/progress-spinner";
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
import { MatInputModule } from "@angular/material/input";
import { MatButtonModule } from "@angular/material/button";
import { MatSelectModule } from "@angular/material/select";
import { JumpTypeResp } from "../../models/jumpType";
import { AircraftResp } from "../../models/aircraft";
@@ -48,6 +49,11 @@ class PickDateAdapter extends NativeDateAdapter {
}
}
interface Equipment {
value: string;
viewValue: string;
}
@Component({
selector: "app-new-jump",
templateUrl: "./new-jump.component.html",
@@ -72,6 +78,7 @@ class PickDateAdapter extends NativeDateAdapter {
ReactiveFormsModule,
MatInputModule,
MatButtonModule,
MatSelectModule,
],
})
export class NewJumpComponent implements OnInit {
@@ -96,6 +103,15 @@ export class NewJumpComponent implements OnInit {
private pendingAddRequest: boolean;
private listOfDropZone: Array<DropZoneResp>;
public maxDate: Date;
public selectedEquipment: string = "";
public listOfEquipment: Array<Equipment> = [
{ value: "", viewValue: "<None>" },
{ value: "Freak 6", viewValue: "Freak 6" },
{ value: "ATC 4", viewValue: "ATC 4" },
{ value: "ATC 2", viewValue: "ATC 2" },
{ value: "Havok", viewValue: "Havok" },
{ value: "Hawk", viewValue: "Hawk" },
];
constructor(
private serviceComm: ServiceComm,
@@ -142,10 +158,12 @@ export class NewJumpComponent implements OnInit {
this.countOfJumps,
this.comments,
this.isSpecial === undefined ? false : this.isSpecial,
this.selectedEquipment,
)
.subscribe(() => {
this.statsService.resetStats();
this.comments = undefined;
this.selectedEquipment = "";
this.withCutaway = false;
this.isSpecial = false;
@@ -233,6 +251,7 @@ export class NewJumpComponent implements OnInit {
this.listOfFilteredDropZone = this.listOfDropZone;
this.comments = undefined;
this.selectedEquipment = "";
this.withCutaway = false;
this.isSpecial = false;
@@ -99,6 +99,7 @@ export class SummaryComponent implements OnInit {
}
public refreshStats() {
this.serviceApi.resetStats();
this.serviceApi.deleteAllCache();
this.tabGroup.selectedIndex = 0;
}
+10 -1
View File
@@ -120,6 +120,7 @@
"NewJump_Count": "Count of jumps",
"NewJump_Comments": "Comments",
"NewJump_Submit": "Submit",
"NewJump_Equipment": "Equipment",
"NewTunnelFlight_ChooseTunnel": "Choose the tunnel",
"NewTunnelFlight_Minutes": "Minutes of the flight",
@@ -143,5 +144,13 @@
"UserProfile_Mail": "E-mail",
"UserProfile_Lastname": "Lastname",
"UserProfile_Firstname": "Firstname",
"UserProfile_Login": "Login"
"UserProfile_Login": "Login",
"GearInfos_Name": "Name",
"GearInfos_Manufacturer": "Manufacturer",
"GearInfos_MinSize": "Min size",
"GearInfos_MaxSize": "Max size",
"GearInfos_AAD": "AAD system",
"GearInfos_MainCanopy": "Main canopy",
"GearInfos_ReserveCanopy": "Reserve canopy"
}
+10 -1
View File
@@ -120,6 +120,7 @@
"NewJump_Count": "Nombre de sauts",
"NewJump_Comments": "Commentaires",
"NewJump_Submit": "Ajouter",
"NewJump_Equipment": "Équipment",
"NewTunnelFlight_ChooseTunnel": "Choisir le tunnel",
"NewTunnelFlight_Minutes": "Temps de vol(minutes)",
@@ -143,5 +144,13 @@
"UserProfile_Mail": "E-mail",
"UserProfile_Lastname": "Nom",
"UserProfile_Firstname": "Prénom",
"UserProfile_Login": "Identifiant"
"UserProfile_Login": "Identifiant",
"GearInfos_Name": "Nom",
"GearInfos_Manufacturer": "Fabriquant",
"GearInfos_MinSize": "Taille min",
"GearInfos_MaxSize": "Taile max",
"GearInfos_AAD": "Système de sécurité",
"GearInfos_MainCanopy": "Voile principale",
"GearInfos_ReserveCanopy": "Voile de secours"
}
+7 -4
View File
@@ -1,7 +1,7 @@
import { GearResp } from './gear';
import { DropZoneResp } from './dropzone';
import { AircraftResp } from './aircraft';
import { JumpTypeResp } from './jumpType';
import { GearResp } from "./gear";
import { DropZoneResp } from "./dropzone";
import { AircraftResp } from "./aircraft";
import { JumpTypeResp } from "./jumpType";
export class JumpReq {
constructor(data: any) {
@@ -19,6 +19,7 @@ export class JumpReq {
public notes: string;
public jumpDate: string;
public isSpecial: boolean;
public equipment: string;
}
export class JumpResp {
@@ -44,6 +45,7 @@ export class JumpResp {
public notes: string;
public jumpDate: Date;
public isSpecial: boolean;
public equipment: string;
}
export class Jump {
@@ -63,4 +65,5 @@ export class Jump {
public notes: string;
public jumpDate: Date;
public isSpecial: boolean;
public equipment: string;
}
@@ -15,18 +15,24 @@ export class GearService extends BaseService {
}
public getListOfGears(): Observable<Array<GearResp>> {
let callToApi = this.http.get<Array<GearResp>>(`${this.apiUrl}/Gear`, { headers: this.headers });
return this.serviceCacheApi.get<Array<GearResp>>(CacheApiKey.Gear, callToApi);
let callToApi = this.http.get<Array<GearResp>>(`${this.apiUrl}/Gear`, {
headers: this.headers,
});
return this.serviceCacheApi.get<Array<GearResp>>(
CacheApiKey.Gear,
callToApi,
);
}
public addGear(name: string,
public addGear(
name: string,
manufacturer: string,
minSize: number,
maxSize: number,
aad: string,
mainCanopy: string,
reserveCanopy: string)
{
reserveCanopy: string,
) {
const bodyNewGear: GearReq = {
id: 0,
name: name,
@@ -35,21 +41,54 @@ export class GearService extends BaseService {
maxSize: maxSize,
aad: aad,
mainCanopy: mainCanopy,
reserveCanopy: reserveCanopy
reserveCanopy: reserveCanopy,
};
this.serviceCacheApi.delete(CacheApiKey.Gear);
return this.http.post(`${this.apiUrl}/Gear`, bodyNewGear, { headers: this.headers});
return this.http.post(`${this.apiUrl}/Gear`, bodyNewGear, {
headers: this.headers,
});
}
public getById(id: number) : Observable<GearResp> {
return this.serviceCacheApi.getByKey<Array<GearResp>>(CacheApiKey.Gear)
.pipe(map(data => {
return data.find(f => f.id === id);
}));
public getById(id: number): Observable<GearResp> {
return this.serviceCacheApi
.getByKey<Array<GearResp>>(CacheApiKey.Gear)
.pipe(
map((data) => {
return data.find((f) => f.id === id);
}),
);
}
public getFromCache(): Observable<Array<GearResp>> {
return this.serviceCacheApi.getByKey<Array<GearResp>>(CacheApiKey.Gear);
}
public updateGear(
id: number,
name: string,
manufacturer: string,
minSize: number,
maxSize: number,
aad: string,
mainCanopy: string,
reserveCanopy: string,
) {
const gearData = {
id: id,
name: name,
manufacturer: manufacturer,
minSize: minSize,
maxSize: maxSize,
aad: aad,
mainCanopy: mainCanopy,
reserveCanopy: reserveCanopy,
};
const bodyUpdatedGear = new GearReq(gearData);
this.serviceCacheApi.delete(CacheApiKey.Gear);
return this.http.put(`${this.apiUrl}/Gear/${id}`, bodyUpdatedGear, {
headers: this.headers,
});
}
}
@@ -1,6 +1,6 @@
import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { DatePipe } from '@angular/common';
import { DatePipe } from "@angular/common";
import { forkJoin, Observable } from "rxjs";
import { map } from "rxjs/operators";
@@ -22,39 +22,56 @@ import { GearService } from "./gear.service";
export class JumpService extends BaseService {
private callsToAdd: Array<Observable<any>>;
constructor(private http: HttpClient,
constructor(
private http: HttpClient,
private dateService: DateService,
private datePipe: DatePipe,
private dropzoneService: DropzoneService,
private aircraftService: AircraftService,
private jumpTypeService: JumpTypeService,
private gearService: GearService) {
private gearService: GearService,
) {
super();
}
public getListOfJumps(): Observable<Array<Jump>> {
return this.http.get<Array<JumpResp>>(`${this.apiUrl}/Jump`, { headers: this.headers })
.pipe(map((response) => {
return this.http
.get<
Array<JumpResp>
>(`${this.apiUrl}/Jump`, { headers: this.headers })
.pipe(
map((response) => {
return this.mapWithDataInCache(response);
}));
}),
);
}
public getJumps(beginIndex: number, endIndex: number): Observable<JumpList> {
return this.http.get<JumpListResp>(`${this.apiUrl}/Jump/${beginIndex}/${endIndex}`, { headers: this.headers })
.pipe(map(response => {
public getJumps(
beginIndex: number,
endIndex: number,
): Observable<JumpList> {
return this.http
.get<JumpListResp>(
`${this.apiUrl}/Jump/${beginIndex}/${endIndex}`,
{ headers: this.headers },
)
.pipe(
map((response) => {
let result: JumpList = {
rows: this.mapWithDataInCache(response.rows),
count: response.count
count: response.count,
};
return new JumpList(result);
}));
}),
);
}
public addListOfJump(selectedJumpType: number,
public addListOfJump(
selectedJumpType: number,
selectedAircraft: number,
selectedDz: number,
selectedRig: number,
selectedGear: number,
withCutaway: boolean,
beginDate: Date,
endDate: Date,
@@ -62,76 +79,94 @@ export class JumpService extends BaseService {
defaultDeployAltitude: number,
countOfJumps: number,
notes: string,
isSpecial: boolean): Observable<any[]> {
isSpecial: boolean,
equipment: string,
): Observable<any[]> {
this.callsToAdd = new Array<Observable<any>>();
const diffInDays = this.dateService.diffBetweenDates(beginDate, endDate) + 1;
const diffInDays =
this.dateService.diffBetweenDates(beginDate, endDate) + 1;
const countOfJumpsPerDay = Math.trunc(countOfJumps / diffInDays);
for (let i = 1; beginDate.getTime() < endDate.getTime(); i++) {
this.addJumps(selectedJumpType,
this.addJumps(
selectedJumpType,
selectedAircraft,
selectedDz,
selectedRig,
selectedGear,
withCutaway,
beginDate,
defaultExitAltitude,
defaultDeployAltitude,
countOfJumpsPerDay,
notes,
isSpecial);
isSpecial,
equipment,
);
beginDate = this.dateService.addDays(beginDate, 1);
}
const restfJumps = countOfJumps - countOfJumpsPerDay * (diffInDays - 1);
this.addJumps(selectedJumpType,
this.addJumps(
selectedJumpType,
selectedAircraft,
selectedDz,
selectedRig,
selectedGear,
withCutaway,
beginDate,
defaultExitAltitude,
defaultDeployAltitude,
restfJumps,
notes,
isSpecial);
isSpecial,
equipment,
);
return forkJoin(this.callsToAdd);
}
public deleteJump(item: Jump) {
this.http.delete(`${this.apiUrl}/Jump/${item.id}`, { headers: this.headers }).subscribe();
this.http
.delete(`${this.apiUrl}/Jump/${item.id}`, { headers: this.headers })
.subscribe();
}
public updateJump(id: number,
public updateJump(
id: number,
isSpecial: boolean,
withCutaway: boolean,
notes: string) {
notes: string,
equipment: string,
) {
const jumpData = {
id: id,
isSpecial: isSpecial,
withCutaway: withCutaway,
notes: notes
notes: notes,
equipment: equipment,
};
const bodyUpdatedJump = new JumpReq(jumpData);
return this.http.put(`${this.apiUrl}/Jump/${id}`,
bodyUpdatedJump,
{ headers: this.headers, });
return this.http.put(`${this.apiUrl}/Jump/${id}`, bodyUpdatedJump, {
headers: this.headers,
});
}
private addJumps(selectedJumpType: number,
private addJumps(
selectedJumpType: number,
selectedAircraft: number,
selectedDz: number,
selectedRig: number,
selectedGear: number,
withCutaway: boolean,
jumpDate: Date,
defaultExitAltitude: number,
defaultDeployAltitude: number,
countOfJumps: number,
notes: string,
isSpecial: boolean) {
isSpecial: boolean,
equipment: string,
) {
for (let i = 0; i < countOfJumps; i++) {
const bodyNewjump: JumpReq = {
jumpTypeId: selectedJumpType,
@@ -140,14 +175,17 @@ export class JumpService extends BaseService {
withCutaway: withCutaway,
exitAltitude: defaultExitAltitude,
deployAltitude: defaultDeployAltitude,
gearId: selectedRig,
gearId: selectedGear,
notes: notes,
id: 0,
jumpDate: this.datePipe.transform(jumpDate, "yyyy-MM-dd"),
isSpecial: isSpecial
isSpecial: isSpecial,
equipment: equipment,
};
let call = this.http.post(`${this.apiUrl}/Jump`, bodyNewjump, { headers: this.headers });
let call = this.http.post(`${this.apiUrl}/Jump`, bodyNewjump, {
headers: this.headers,
});
this.callsToAdd.push(call);
}
@@ -155,21 +193,29 @@ export class JumpService extends BaseService {
private mapWithDataInCache(apiResp: Array<JumpResp>): Array<Jump> {
let allDropzones: Array<DropZoneResp>;
this.dropzoneService.getFromCache().subscribe(data => { allDropzones = data; });
this.dropzoneService.getFromCache().subscribe((data) => {
allDropzones = data;
});
let allAircrafts: Array<AircraftResp>;
this.aircraftService.getFromCache().subscribe(data => { allAircrafts = data; });
this.aircraftService.getFromCache().subscribe((data) => {
allAircrafts = data;
});
let allJumpType: Array<JumpTypeResp>;
this.jumpTypeService.getFromCache().subscribe(data => { allJumpType = data; });
this.jumpTypeService.getFromCache().subscribe((data) => {
allJumpType = data;
});
let allGears: Array<GearResp>;
this.gearService.getFromCache().subscribe(data => { allGears = data; });
this.gearService.getFromCache().subscribe((data) => {
allGears = data;
});
return apiResp.map((data) => {
let tmp = new Jump(data);
tmp.dropZone = allDropzones.find(d => d.id == data.dropZoneId);
tmp.aircraft = allAircrafts.find(d => d.id == data.aircraftId);
tmp.jumpType = allJumpType.find(d => d.id == data.jumpTypeId);
tmp.gear = allGears.find(d => d.id == data.gearId);
tmp.dropZone = allDropzones.find((d) => d.id == data.dropZoneId);
tmp.aircraft = allAircrafts.find((d) => d.id == data.aircraftId);
tmp.jumpType = allJumpType.find((d) => d.id == data.jumpTypeId);
tmp.gear = allGears.find((d) => d.id == data.gearId);
return tmp;
});
+17
View File
@@ -0,0 +1,17 @@
# Manual
## To build an image "skydivelogs" with the version "1.6.0":
podman build . -t skydivelogs:1.6.0
## To run ab image to container with volume :
podman run -v ./Front/skydivelogs-app/src/config:/usr/share/nginx/html/config:z -v ./Back/skydiveLogs-api/Data:/app/Data:z -d -p 5080:80/tcp --name Skydivelogs-1.6.0 -it skydivelogs:1.6.0
## To save the image before to updload to the server :
podman save --output skydivelogs-1.6.0.tar skydivelogs:1.6.0
## Updload to the server :
scp -P 5022 skydivelogs-1.6.0.tar administrator@51.75.68.58:~
# By a registry
podman login home.git.sebastienandre.com
podman build -t home.git.sebastienandre.com/sandre/skydivelogs:1.7.0 .
podman push home.git.sebastienandre.com/sandre/skydivelogs:1.7.0
-11
View File
@@ -1,11 +0,0 @@
To build an image "skydivelogs" with the version "1.6.0":
podman build . -t skydivelogs:1.6.0
To run ab image to container with volume :
podman run -v ./Front/skydivelogs-app/src/config:/usr/share/nginx/html/config:z -v ./Back/skydiveLogs-api/Data:/app/Data:z -d -p 5080:80/tcp --name Skydivelogs-1.6.0 -it skydivelogs:1.6.0
To save the image before to updload to the server :
podman save --output skydivelogs-1.6.0.tar skydivelogs:1.6.0
Updload to the server :
scp -P 5022 skydivelogs-1.6.0.tar administrator@51.75.68.58:~