Store the user statistics for the performance.
This commit is contained in:
@@ -26,6 +26,7 @@ namespace skydiveLogs_api.Infrastructure.Interfaces
|
||||
ILiteCollection<UserImage> CollOfImage { get; }
|
||||
ILiteCollection<Jump> CollOfJump { get; }
|
||||
ILiteCollection<JumpType> CollOfJumpType { get; }
|
||||
ILiteCollection<UserStats> CollOfStats { get; }
|
||||
ILiteCollection<User> CollOfUser { get; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
@@ -21,6 +21,8 @@ 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");
|
||||
@@ -52,6 +54,7 @@ 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>();
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
72
Back/skydiveLogs-api.Infrastructure/UserStatsRepository.cs
Normal file
72
Back/skydiveLogs-api.Infrastructure/UserStatsRepository.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
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 UserStatsRepository : IUserStatsRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public UserStatsRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.CollOfStats;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public int Add(UserStats newStats)
|
||||
{
|
||||
int result;
|
||||
|
||||
try
|
||||
{
|
||||
var tmp = _col.Insert(newStats);
|
||||
result = tmp.AsInt32;
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public IEnumerable<UserStats> GetAll()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public UserStats GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.SingleOrDefault();
|
||||
}
|
||||
|
||||
public UserStats GetById(int id)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public bool Update(UserStats stats)
|
||||
{
|
||||
return _col.Update(stats);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly ILiteCollection<UserStats> _col;
|
||||
private readonly IDataProvider _dataProvider;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user