Split tables for the stats (#6)
Reviewed-on: #6 Co-authored-by: sandre <perso@sebastienandre.com> Co-committed-by: sandre <perso@sebastienandre.com>
This commit was merged in pull request #6.
This commit is contained in:
@@ -30,12 +30,30 @@ namespace skydiveLogs_api.Infrastructure.Interfaces
|
||||
|
||||
ILiteCollection<JumpType> CollOfJumpType { get; }
|
||||
|
||||
ILiteCollection<UserStats> CollOfStats { get; }
|
||||
|
||||
ILiteCollection<User> CollOfUser { get; }
|
||||
|
||||
|
||||
ILiteCollection<TunnelFlight> CollOfTunnelFlight { get; }
|
||||
|
||||
ILiteCollection<StatsByAircraft> CollOfStatsByAircraft { get; }
|
||||
|
||||
ILiteCollection<StatsByDz> CollOfStatsByDz { get; }
|
||||
|
||||
ILiteCollection<StatsByGear> CollOfStatsByGear { get; }
|
||||
|
||||
ILiteCollection<StatsByJumpType> CollOfStatsByJumpType { get; }
|
||||
|
||||
ILiteCollection<StatsByYear> CollOfStatsByYear { get; }
|
||||
|
||||
ILiteCollection<StatsForLastMonthByDz> CollOfStatsForLastMonthByDz { get; }
|
||||
|
||||
ILiteCollection<StatsForLastMonthByJumpType> CollOfStatsForLastMonthByJumpType { get; }
|
||||
|
||||
ILiteCollection<StatsForLastYearByDz> CollOfStatsForLastYearByDz { get; }
|
||||
|
||||
ILiteCollection<StatsForLastYearByJumpType> CollOfStatsForLastYearByJumpType { get; }
|
||||
|
||||
ILiteCollection<StatsByYearByJumpType> CollOfStatsByYearByJumpType { get; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,6 @@ namespace skydiveLogs_api.Infrastructure
|
||||
|
||||
BsonMapper.Global.Entity<UserImage>().DbRef(x => x.User, "User");
|
||||
|
||||
BsonMapper.Global.Entity<UserStats>().DbRef(x => x.User, "User");
|
||||
|
||||
BsonMapper.Global.Entity<Gear>().DbRef(x => x.User, "User");
|
||||
|
||||
BsonMapper.Global.Entity<FavoriteDropZone>().DbRef(x => x.User, "User");
|
||||
@@ -31,6 +29,17 @@ namespace skydiveLogs_api.Infrastructure
|
||||
BsonMapper.Global.Entity<TunnelFlight>().DbRef(x => x.Tunnel, "DropZone");
|
||||
BsonMapper.Global.Entity<TunnelFlight>().DbRef(x => x.JumpType, "JumpType");
|
||||
BsonMapper.Global.Entity<TunnelFlight>().DbRef(x => x.User, "User");
|
||||
|
||||
BsonMapper.Global.Entity<StatsByAircraft>().DbRef(x => x.User, "User");
|
||||
BsonMapper.Global.Entity<StatsByDz>().DbRef(x => x.User, "User");
|
||||
BsonMapper.Global.Entity<StatsByGear>().DbRef(x => x.User, "User");
|
||||
BsonMapper.Global.Entity<StatsByJumpType>().DbRef(x => x.User, "User");
|
||||
BsonMapper.Global.Entity<StatsByYear>().DbRef(x => x.User, "User");
|
||||
BsonMapper.Global.Entity<StatsForLastMonthByDz>().DbRef(x => x.User, "User");
|
||||
BsonMapper.Global.Entity<StatsForLastMonthByJumpType>().DbRef(x => x.User, "User");
|
||||
BsonMapper.Global.Entity<StatsForLastYearByDz>().DbRef(x => x.User, "User");
|
||||
BsonMapper.Global.Entity<StatsForLastYearByJumpType>().DbRef(x => x.User, "User");
|
||||
BsonMapper.Global.Entity<StatsByYearByJumpType>().DbRef(x => x.User, "User");
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
@@ -58,10 +67,18 @@ namespace skydiveLogs_api.Infrastructure
|
||||
public ILiteCollection<UserImage> CollOfImage => _db.GetCollection<UserImage>();
|
||||
public ILiteCollection<Jump> CollOfJump => _db.GetCollection<Jump>();
|
||||
public ILiteCollection<JumpType> CollOfJumpType => _db.GetCollection<JumpType>();
|
||||
public ILiteCollection<UserStats> CollOfStats => _db.GetCollection<UserStats>();
|
||||
public ILiteCollection<User> CollOfUser => _db.GetCollection<User>();
|
||||
public ILiteCollection<TunnelFlight> CollOfTunnelFlight => _db.GetCollection<TunnelFlight>();
|
||||
|
||||
public ILiteCollection<StatsByAircraft> CollOfStatsByAircraft => _db.GetCollection<StatsByAircraft>();
|
||||
public ILiteCollection<StatsByDz> CollOfStatsByDz => _db.GetCollection<StatsByDz>();
|
||||
public ILiteCollection<StatsByGear> CollOfStatsByGear => _db.GetCollection<StatsByGear>();
|
||||
public ILiteCollection<StatsByJumpType> CollOfStatsByJumpType => _db.GetCollection<StatsByJumpType>();
|
||||
public ILiteCollection<StatsByYear> CollOfStatsByYear => _db.GetCollection<StatsByYear>();
|
||||
public ILiteCollection<StatsForLastMonthByDz> CollOfStatsForLastMonthByDz => _db.GetCollection<StatsForLastMonthByDz>();
|
||||
public ILiteCollection<StatsForLastMonthByJumpType> CollOfStatsForLastMonthByJumpType => _db.GetCollection<StatsForLastMonthByJumpType>();
|
||||
public ILiteCollection<StatsForLastYearByDz> CollOfStatsForLastYearByDz => _db.GetCollection<StatsForLastYearByDz>();
|
||||
public ILiteCollection<StatsForLastYearByJumpType> CollOfStatsForLastYearByJumpType => _db.GetCollection<StatsForLastYearByJumpType>();
|
||||
public ILiteCollection<StatsByYearByJumpType> CollOfStatsByYearByJumpType => _db.GetCollection<StatsByYearByJumpType>();
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Fields
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
using LiteDB;
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainService.Repositories;
|
||||
using skydiveLogs_api.Infrastructure.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class StatsByAircraftRepository : IStatsByAircraftRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public StatsByAircraftRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.CollOfStatsByAircraft;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public int Add(IEnumerable<StatsByAircraft> newStats)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var newStat in newStats)
|
||||
{
|
||||
var tmp = _col.Insert(newStats);
|
||||
result = tmp;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public IEnumerable<StatsByAircraft> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public bool Update(IEnumerable<StatsByAircraft> updatedStats, User user)
|
||||
{
|
||||
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
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly ILiteCollection<StatsByAircraft> _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;
|
||||
@@ -6,28 +6,31 @@ using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class UserStatsRepository : IUserStatsRepository
|
||||
public class StatsByDzRepository : IStatsByDzRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public UserStatsRepository(IDataProvider dataProvider)
|
||||
public StatsByDzRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.CollOfStats;
|
||||
_col = _dataProvider.CollOfStatsByDz;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public int Add(UserStats newStats)
|
||||
public int Add(IEnumerable<StatsByDz> 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
|
||||
{
|
||||
@@ -37,39 +40,33 @@ namespace skydiveLogs_api.Infrastructure
|
||||
return result;
|
||||
}
|
||||
|
||||
public IEnumerable<UserStats> GetAll()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public UserStats GetAll(User user)
|
||||
public IEnumerable<StatsByDz> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.SingleOrDefault();
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public UserStats GetById(int id)
|
||||
public bool Update(IEnumerable<StatsByDz> updatedStats, User user)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
Delete(user);
|
||||
var tmp = Add(updatedStats);
|
||||
|
||||
return tmp != 0;
|
||||
}
|
||||
|
||||
public int GetCount()
|
||||
public bool Delete(User user)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public bool Update(UserStats stats)
|
||||
{
|
||||
return _col.Update(stats);
|
||||
var tmp = _col.DeleteMany(s => s.User.Id == user.Id);
|
||||
return tmp != 0;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly ILiteCollection<UserStats> _col;
|
||||
private readonly ILiteCollection<StatsByDz> _col;
|
||||
private readonly IDataProvider _dataProvider;
|
||||
|
||||
#endregion Private Fields
|
||||
74
Back/skydiveLogs-api.Infrastructure/StatsByGearRepository.cs
Normal file
74
Back/skydiveLogs-api.Infrastructure/StatsByGearRepository.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using LiteDB;
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainService.Repositories;
|
||||
using skydiveLogs_api.Infrastructure.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class StatsByGearRepository : IStatsByGearRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public StatsByGearRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.CollOfStatsByGear;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public int Add(IEnumerable<StatsByGear> newStats)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var newStat in newStats)
|
||||
{
|
||||
var tmp = _col.Insert(newStats);
|
||||
result = tmp;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public IEnumerable<StatsByGear> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public bool Update(IEnumerable<StatsByGear> updatedStats, User user)
|
||||
{
|
||||
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
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly ILiteCollection<StatsByGear> _col;
|
||||
private readonly IDataProvider _dataProvider;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using LiteDB;
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainService.Repositories;
|
||||
using skydiveLogs_api.Infrastructure.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class StatsByJumpTypeRepository : IStatsByJumpTypeRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public StatsByJumpTypeRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.CollOfStatsByJumpType;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public int Add(IEnumerable<StatsByJumpType> newStats)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var newStat in newStats)
|
||||
{
|
||||
var tmp = _col.Insert(newStats);
|
||||
result = tmp;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public IEnumerable<StatsByJumpType> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public bool Update(IEnumerable<StatsByJumpType> updatedStats, User user)
|
||||
{
|
||||
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
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly ILiteCollection<StatsByJumpType> _col;
|
||||
private readonly IDataProvider _dataProvider;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using LiteDB;
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainService.Repositories;
|
||||
using skydiveLogs_api.Infrastructure.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class StatsByYearByJumpTypeRepository : IStatsByYearByJumpTypeRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public StatsByYearByJumpTypeRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.CollOfStatsByYearByJumpType;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public int Add(IEnumerable<StatsByYearByJumpType> newStats)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var newStat in newStats)
|
||||
{
|
||||
var tmp = _col.Insert(newStats);
|
||||
result = tmp;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public IEnumerable<StatsByYearByJumpType> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public bool Update(IEnumerable<StatsByYearByJumpType> updatedStats, User user)
|
||||
{
|
||||
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
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly ILiteCollection<StatsByYearByJumpType> _col;
|
||||
private readonly IDataProvider _dataProvider;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
74
Back/skydiveLogs-api.Infrastructure/StatsByYearRepository.cs
Normal file
74
Back/skydiveLogs-api.Infrastructure/StatsByYearRepository.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System.Collections.Generic;
|
||||
using LiteDB;
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainService.Repositories;
|
||||
using skydiveLogs_api.Infrastructure.Interfaces;
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class StatsByYearRepository : IStatsByYearRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public StatsByYearRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.CollOfStatsByYear;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public int Add(IEnumerable<StatsByYear> newStats)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var newStat in newStats)
|
||||
{
|
||||
var tmp = _col.Insert(newStats);
|
||||
result = tmp;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public IEnumerable<StatsByYear> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public bool Update(IEnumerable<StatsByYear> updatedStats, User user)
|
||||
{
|
||||
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
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly ILiteCollection<StatsByYear> _col;
|
||||
private readonly IDataProvider _dataProvider;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using LiteDB;
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainService.Repositories;
|
||||
using skydiveLogs_api.Infrastructure.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class StatsForLastMonthByDzRepository : IStatsForLastMonthByDzRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public StatsForLastMonthByDzRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.CollOfStatsForLastMonthByDz;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public int Add(IEnumerable<StatsForLastMonthByDz> newStats)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var newStat in newStats)
|
||||
{
|
||||
var tmp = _col.Insert(newStats);
|
||||
result = tmp;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public IEnumerable<StatsForLastMonthByDz> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public bool Update(IEnumerable<StatsForLastMonthByDz> updatedStats, User user)
|
||||
{
|
||||
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
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly ILiteCollection<StatsForLastMonthByDz> _col;
|
||||
private readonly IDataProvider _dataProvider;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using LiteDB;
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainService.Repositories;
|
||||
using skydiveLogs_api.Infrastructure.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class StatsForLastMonthByJumpTypeRepository : IStatsForLastMonthByJumpTypeRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public StatsForLastMonthByJumpTypeRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.CollOfStatsForLastMonthByJumpType;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public int Add(IEnumerable<StatsForLastMonthByJumpType> newStats)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var newStat in newStats)
|
||||
{
|
||||
var tmp = _col.Insert(newStats);
|
||||
result = tmp;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public IEnumerable<StatsForLastMonthByJumpType> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public bool Update(IEnumerable<StatsForLastMonthByJumpType> updatedStats, User user)
|
||||
{
|
||||
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
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly ILiteCollection<StatsForLastMonthByJumpType> _col;
|
||||
private readonly IDataProvider _dataProvider;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using LiteDB;
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainService.Repositories;
|
||||
using skydiveLogs_api.Infrastructure.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class StatsForLastYearByDzRepository : IStatsForLastYearByDzRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public StatsForLastYearByDzRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.CollOfStatsForLastYearByDz;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public int Add(IEnumerable<StatsForLastYearByDz> newStats)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var newStat in newStats)
|
||||
{
|
||||
var tmp = _col.Insert(newStats);
|
||||
result = tmp;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public IEnumerable<StatsForLastYearByDz> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public bool Update(IEnumerable<StatsForLastYearByDz> updatedStats, User user)
|
||||
{
|
||||
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
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly ILiteCollection<StatsForLastYearByDz> _col;
|
||||
private readonly IDataProvider _dataProvider;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using LiteDB;
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainService.Repositories;
|
||||
using skydiveLogs_api.Infrastructure.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class StatsForLastYearByJumpTypeRepository : IStatsForLastYearByJumpTypeRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public StatsForLastYearByJumpTypeRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.CollOfStatsForLastYearByJumpType;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public int Add(IEnumerable<StatsForLastYearByJumpType> newStats)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var newStat in newStats)
|
||||
{
|
||||
var tmp = _col.Insert(newStats);
|
||||
result = tmp;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public IEnumerable<StatsForLastYearByJumpType> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public bool Update(IEnumerable<StatsForLastYearByJumpType> updatedStats, User user)
|
||||
{
|
||||
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
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly ILiteCollection<StatsForLastYearByJumpType> _col;
|
||||
private readonly IDataProvider _dataProvider;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user