This commit is contained in:
2026-01-23 22:52:51 +01:00
parent e84d6e98c9
commit 668f321c54
51 changed files with 580 additions and 3329 deletions

View File

@@ -1,3 +1,4 @@
using System.Collections.Generic;
using LiteDB;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories;
@@ -5,7 +6,7 @@ using skydiveLogs_api.Infrastructure.Interfaces;
namespace skydiveLogs_api.Infrastructure
{
public class StatsByYearRepository : IStatsRepository<StatsByYear>
public class StatsByYearRepository : IStatsByYearRepository
{
#region Public Constructors
@@ -19,14 +20,17 @@ namespace skydiveLogs_api.Infrastructure
#region Public Methods
public int Add(StatsByYear newStats)
public int Add(IEnumerable<StatsByYear> newStats)
{
int result;
int result = 0;
try
{
var tmp = _col.Insert(newStats);
result = tmp.AsInt32;
foreach (var newStat in newStats)
{
var tmp = _col.Insert(newStats);
result = tmp;
}
}
catch
{
@@ -36,17 +40,26 @@ namespace skydiveLogs_api.Infrastructure
return result;
}
public StatsByYear GetAll(User user)
public IEnumerable<StatsByYear> GetAll(User user)
{
return _col.Include(x => x.User)
.Query()
.Where(j => j.User.Id == user.Id)
.SingleOrDefault();
.ToList();
}
public bool Update(StatsByYear stats)
public bool Update(IEnumerable<StatsByYear> updatedStats, User user)
{
return _col.Update(stats);
Delete(user);
var tmp = Add(updatedStats);
return tmp != 0;
}
public bool Delete(User user)
{
var tmp = _col.DeleteMany(s => s.User.Id == user.Id);
return tmp != 0;
}
#endregion Public Methods