Add comment by AI
This commit is contained in:
@@ -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="DropZoneRepository"/> class
|
||||
/// </summary>
|
||||
/// <param name="dataProvider">The data provider to use for data access</param>
|
||||
public DropZoneRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
@@ -21,13 +25,18 @@ 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 add</param>
|
||||
/// <returns>The number of rows affected (0 if insert failed)</returns>
|
||||
public int Add(DropZone newDropZone)
|
||||
{
|
||||
int result;
|
||||
|
||||
try
|
||||
{
|
||||
var tmp = _col.Insert(newDz);
|
||||
var tmp = _col.Insert(newDropZone);
|
||||
result = tmp.AsInt32;
|
||||
}
|
||||
catch
|
||||
@@ -38,24 +47,42 @@ namespace skydiveLogs_api.Infrastructure
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all drop zones from the database
|
||||
/// </summary>
|
||||
/// <returns>A collection of all drop zone instances</returns>
|
||||
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</param>
|
||||
/// <returns>The drop zone instance or null if not found</returns>
|
||||
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</returns>
|
||||
public int GetCount()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public bool Update(DropZone updatedDz)
|
||||
/// <summary>
|
||||
/// Updates an existing drop zone in the database
|
||||
/// </summary>
|
||||
/// <param name="dropZone">The drop zone instance to update</param>
|
||||
/// <returns>True if the update was successful, false otherwise</returns>
|
||||
public bool Update(DropZone dropZone)
|
||||
{
|
||||
return _col.Update(updatedDz);
|
||||
return _col.Update(dropZone);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
@@ -67,4 +94,4 @@ namespace skydiveLogs_api.Infrastructure
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user