Update about the relation column "User" for the images

and begin to add a column in "Aircraft"
This commit is contained in:
Sébastien André
2020-07-30 18:29:41 +02:00
parent caa7215b71
commit eee6f596ac
12 changed files with 27 additions and 10 deletions

View File

@@ -19,7 +19,15 @@ namespace skydiveLogs_api.Data
public IEnumerable<Image> GetAll()
{
return _col.FindAll().ToList();
throw new System.NotImplementedException();
}
public IEnumerable<Image> GetAll(User user)
{
return _col.Include(x => x.User)
.Query()
.Where(j => j.User == user)
.ToList();
}
public Image GetById(int id)

View File

@@ -1,9 +1,11 @@
using skydiveLogs_api.Model;
using System.Collections.Generic;
using skydiveLogs_api.Model;
namespace skydiveLogs_api.Data.Interface
{
public interface IImageRepository : IRepository<Image>
{
IEnumerable<Image> GetAll(User user);
}
}

View File

@@ -5,7 +5,7 @@ namespace skydiveLogs_api.Data.Interface
{
public interface IJumpRepository : IRepository<Jump>
{
IEnumerable<Jump> GetAll(int userId);
IEnumerable<Jump> GetAll(User user);
}
}

View File

@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using LiteDB;
@@ -17,14 +16,15 @@ namespace skydiveLogs_api.Data
_col = _dataProvider.CollOfJump;
}
public IEnumerable<Jump> GetAll(int userId)
public IEnumerable<Jump> GetAll(User user)
{
return _col.Include(x => x.Aircraft)
.Include(x => x.DropZone)
.Include(x => x.Gear)
.Include(x => x.JumpType)
.FindAll()
.Where(j => j.UserId == userId)
.Include(x => x.User)
.Query()
.Where(j => j.User == user)
.ToList();
}

View File

@@ -14,6 +14,7 @@ namespace skydiveLogs_api.Data
BsonMapper.Global.Entity<Jump>().DbRef(x => x.Aircraft, "Aircraft");
BsonMapper.Global.Entity<Jump>().DbRef(x => x.DropZone, "DropZone");
BsonMapper.Global.Entity<Jump>().DbRef(x => x.Gear, "Gear");
BsonMapper.Global.Entity<Jump>().DbRef(x => x.User, "User");
BsonMapper.Global.Entity<Image>().DbRef(x => x.User, "User");
}