Add some update
Add a TODO for the ideas
This commit is contained in:
@@ -21,13 +21,20 @@ namespace skydiveLogs_api.Infrastructure.Interfaces
|
||||
ILiteCollection<DropZone> CollOfDropZone { get; }
|
||||
|
||||
ILiteCollection<FavoriteDropZone> CollOfFavoriteDropZone { get; }
|
||||
|
||||
ILiteCollection<Gear> CollOfGear { get; }
|
||||
|
||||
ILiteCollection<UserImage> CollOfImage { get; }
|
||||
|
||||
ILiteCollection<Jump> CollOfJump { get; }
|
||||
|
||||
ILiteCollection<JumpType> CollOfJumpType { get; }
|
||||
|
||||
ILiteCollection<UserStats> CollOfStats { get; }
|
||||
|
||||
ILiteCollection<User> CollOfUser { get; }
|
||||
|
||||
ILiteCollection<TunnelFlight> CollOfTunnelFlight { get; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace skydiveLogs_api.Infrastructure
|
||||
|
||||
BsonMapper.Global.Entity<FavoriteDropZone>().DbRef(x => x.User, "User");
|
||||
BsonMapper.Global.Entity<FavoriteDropZone>().DbRef(x => x.DropZone, "DropZone");
|
||||
|
||||
BsonMapper.Global.Entity<TunnelFlight>().DbRef(x => x.Tunnel, "DropZone");
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
@@ -56,6 +58,7 @@ namespace skydiveLogs_api.Infrastructure
|
||||
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>();
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
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 TunnelFlightRepository : ITunnelFlightRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public TunnelFlightRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.CollOfTunnelFlight;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public int Add(TunnelFlight newTunnelFlight)
|
||||
{
|
||||
int result;
|
||||
|
||||
try
|
||||
{
|
||||
var tmp = _col.Insert(newTunnelFlight);
|
||||
result = tmp.AsInt32;
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool DeleteById(int id)
|
||||
{
|
||||
return _col.Delete(new BsonValue(id));
|
||||
}
|
||||
|
||||
public IEnumerable<TunnelFlight> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.Tunnel)
|
||||
.Find(j => j.User.Id == user.Id);
|
||||
}
|
||||
|
||||
public IEnumerable<TunnelFlight> GetAll()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<TunnelFlight> GetBetweenIndex(User user, int beginIndex, int endIndex)
|
||||
{
|
||||
return _col.Include(x => x.DropZone)
|
||||
.Query()
|
||||
.OrderByDescending(j => j.FlightDate)
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.Limit(endIndex - beginIndex)
|
||||
.Offset(beginIndex)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public TunnelFlight GetById(int id)
|
||||
{
|
||||
return _col.FindById(new BsonValue(id));
|
||||
}
|
||||
|
||||
public int GetCount(User user)
|
||||
{
|
||||
return _col.Count(j => j.User.Id == user.Id);
|
||||
}
|
||||
|
||||
public int GetCount()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public bool Update(TunnelFlight updatedTunnelFlight)
|
||||
{
|
||||
return _col.Update(updatedTunnelFlight);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly ILiteCollection<TunnelFlight> _col;
|
||||
private readonly IDataProvider _dataProvider;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user