Refacto
This commit is contained in:
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class StatsByAircraftRepository : IStatsRepository<StatsByAircraft>
|
||||
public class StatsByAircraftRepository : IStatsByAircraftRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class StatsByDzRepository : IStatsRepository<StatsByDz>
|
||||
public class StatsByDzRepository : IStatsByDzRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
@@ -20,14 +20,17 @@ namespace skydiveLogs_api.Infrastructure
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public int Add(StatsByDz 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,17 +40,26 @@ namespace skydiveLogs_api.Infrastructure
|
||||
return result;
|
||||
}
|
||||
|
||||
public StatsByDz 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 bool Update(StatsByDz stats)
|
||||
public bool Update(IEnumerable<StatsByDz> 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
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class StatsByGearRepository : IStatsRepository<StatsByGear>
|
||||
public class StatsByGearRepository : IStatsByGearRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
@@ -20,14 +20,17 @@ namespace skydiveLogs_api.Infrastructure
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public int Add(StatsByGear newStats)
|
||||
public int Add(IEnumerable<StatsByGear> 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,17 +40,26 @@ namespace skydiveLogs_api.Infrastructure
|
||||
return result;
|
||||
}
|
||||
|
||||
public StatsByGear GetAll(User user)
|
||||
public IEnumerable<StatsByGear> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.SingleOrDefault();
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public bool Update(StatsByGear stats)
|
||||
public bool Update(IEnumerable<StatsByGear> 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
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class StatsByJumpTypeRepository : IStatsRepository<StatsByJumpType>
|
||||
public class StatsByJumpTypeRepository : IStatsByJumpTypeRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
@@ -20,14 +20,17 @@ namespace skydiveLogs_api.Infrastructure
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public int Add(StatsByJumpType newStats)
|
||||
public int Add(IEnumerable<StatsByJumpType> 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,17 +40,26 @@ namespace skydiveLogs_api.Infrastructure
|
||||
return result;
|
||||
}
|
||||
|
||||
public StatsByJumpType GetAll(User user)
|
||||
public IEnumerable<StatsByJumpType> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.SingleOrDefault();
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public bool Update(StatsByJumpType stats)
|
||||
public bool Update(IEnumerable<StatsByJumpType> 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
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class StatsByYearByJumpTypeRepository : IStatsRepository<StatsByYearByJumpType>
|
||||
public class StatsByYearByJumpTypeRepository : IStatsByYearByJumpTypeRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
@@ -20,14 +20,17 @@ namespace skydiveLogs_api.Infrastructure
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public int Add(StatsByYearByJumpType newStats)
|
||||
public int Add(IEnumerable<StatsByYearByJumpType> 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,17 +40,26 @@ namespace skydiveLogs_api.Infrastructure
|
||||
return result;
|
||||
}
|
||||
|
||||
public StatsByYearByJumpType GetAll(User user)
|
||||
public IEnumerable<StatsByYearByJumpType> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.SingleOrDefault();
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public bool Update(StatsByYearByJumpType stats)
|
||||
public bool Update(IEnumerable<StatsByYearByJumpType> 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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class StatsForLastMonthByDzRepository : IStatsRepository<StatsForLastMonthByDz>
|
||||
public class StatsForLastMonthByDzRepository : IStatsForLastMonthByDzRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
@@ -20,14 +20,17 @@ namespace skydiveLogs_api.Infrastructure
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public int Add(StatsForLastMonthByDz newStats)
|
||||
public int Add(IEnumerable<StatsForLastMonthByDz> 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,17 +40,26 @@ namespace skydiveLogs_api.Infrastructure
|
||||
return result;
|
||||
}
|
||||
|
||||
public StatsForLastMonthByDz GetAll(User user)
|
||||
public IEnumerable<StatsForLastMonthByDz> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.SingleOrDefault();
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public bool Update(StatsForLastMonthByDz stats)
|
||||
public bool Update(IEnumerable<StatsForLastMonthByDz> 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
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class StatsForLastMonthByJumpTypeRepository : IStatsRepository<StatsForLastMonthByJumpType>
|
||||
public class StatsForLastMonthByJumpTypeRepository : IStatsForLastMonthByJumpTypeRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
@@ -20,14 +20,17 @@ namespace skydiveLogs_api.Infrastructure
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public int Add(StatsForLastMonthByJumpType newStats)
|
||||
public int Add(IEnumerable<StatsForLastMonthByJumpType> 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,17 +40,26 @@ namespace skydiveLogs_api.Infrastructure
|
||||
return result;
|
||||
}
|
||||
|
||||
public StatsForLastMonthByJumpType GetAll(User user)
|
||||
public IEnumerable<StatsForLastMonthByJumpType> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.SingleOrDefault();
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public bool Update(StatsForLastMonthByJumpType stats)
|
||||
public bool Update(IEnumerable<StatsForLastMonthByJumpType> 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
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class StatsForLastYearByDzRepository : IStatsRepository<StatsForLastYearByDz>
|
||||
public class StatsForLastYearByDzRepository : IStatsForLastYearByDzRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
@@ -20,14 +20,17 @@ namespace skydiveLogs_api.Infrastructure
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public int Add(StatsForLastYearByDz newStats)
|
||||
public int Add(IEnumerable<StatsForLastYearByDz> 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,17 +40,26 @@ namespace skydiveLogs_api.Infrastructure
|
||||
return result;
|
||||
}
|
||||
|
||||
public StatsForLastYearByDz GetAll(User user)
|
||||
public IEnumerable<StatsForLastYearByDz> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.SingleOrDefault();
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public bool Update(StatsForLastYearByDz stats)
|
||||
public bool Update(IEnumerable<StatsForLastYearByDz> 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
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class StatsForLastYearByJumpTypeRepository : IStatsRepository<StatsForLastYearByJumpType>
|
||||
public class StatsForLastYearByJumpTypeRepository : IStatsForLastYearByJumpTypeRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
@@ -20,14 +20,17 @@ namespace skydiveLogs_api.Infrastructure
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public int Add(StatsForLastYearByJumpType newStats)
|
||||
public int Add(IEnumerable<StatsForLastYearByJumpType> 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,17 +40,26 @@ namespace skydiveLogs_api.Infrastructure
|
||||
return result;
|
||||
}
|
||||
|
||||
public StatsForLastYearByJumpType GetAll(User user)
|
||||
public IEnumerable<StatsForLastYearByJumpType> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.SingleOrDefault();
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public bool Update(StatsForLastYearByJumpType stats)
|
||||
public bool Update(IEnumerable<StatsForLastYearByJumpType> 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
|
||||
|
||||
Reference in New Issue
Block a user