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:
@@ -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;
|
||||
@@ -69,4 +98,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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}";
|
||||
@@ -63,4 +95,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -124,4 +158,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -90,4 +122,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
@@ -193,4 +199,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -96,4 +133,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -74,4 +102,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -65,4 +72,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -65,4 +72,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -65,4 +72,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -65,4 +72,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -66,4 +73,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -65,4 +72,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -70,4 +77,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -70,4 +77,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -69,4 +76,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -71,4 +77,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
@@ -191,4 +238,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public TunnelFlightService(IJumpTypeService jumpTypeService,
|
||||
public TunnelFlightService(IJumpTypeService jumpTypeService,
|
||||
ITunnelFlightRepository tunnelFlightRepository,
|
||||
IDropZoneService dropZoneService,
|
||||
IIdentityService identityService)
|
||||
@@ -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);
|
||||
@@ -76,7 +107,13 @@ 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);
|
||||
@@ -125,4 +170,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
@@ -70,4 +79,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
@@ -56,4 +78,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
@@ -69,7 +85,7 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
{
|
||||
Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(encryptionKey,
|
||||
new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 },
|
||||
3,
|
||||
3,
|
||||
HashAlgorithmName.SHA256);
|
||||
encryptor.Key = pdb.GetBytes(32);
|
||||
encryptor.IV = pdb.GetBytes(16);
|
||||
@@ -97,4 +113,4 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user