Update the repository and model to have the join between the models
This commit is contained in:
@@ -19,7 +19,7 @@ namespace skydiveLogs_api.Business
|
||||
{
|
||||
var allJumps = _jumpRepository.GetAll();
|
||||
|
||||
return allJumps.GroupBy(j => j.AircraftId,
|
||||
return allJumps.GroupBy(j => j.Aircraft.Id,
|
||||
j => j,
|
||||
(groupby, jumps) => new Statistic
|
||||
{
|
||||
@@ -33,7 +33,7 @@ namespace skydiveLogs_api.Business
|
||||
{
|
||||
var allJumps = _jumpRepository.GetAll();
|
||||
|
||||
return allJumps.GroupBy(j => j.DropZoneId,
|
||||
return allJumps.GroupBy(j => j.DropZone.Id,
|
||||
j => j,
|
||||
(groupby, jumps) => new Statistic
|
||||
{
|
||||
@@ -47,7 +47,7 @@ namespace skydiveLogs_api.Business
|
||||
{
|
||||
var allJumps = _jumpRepository.GetAll();
|
||||
|
||||
return allJumps.GroupBy(j => j.JumpTypeId,
|
||||
return allJumps.GroupBy(j => j.JumpType.Id,
|
||||
j => j,
|
||||
(groupby, jumps) => new Statistic
|
||||
{
|
||||
@@ -61,7 +61,7 @@ namespace skydiveLogs_api.Business
|
||||
{
|
||||
var allJumps = _jumpRepository.GetAll();
|
||||
|
||||
return allJumps.GroupBy(j => j.GearId,
|
||||
return allJumps.GroupBy(j => j.Gear.Id,
|
||||
j => j,
|
||||
(groupby, jumps) => new Statistic
|
||||
{
|
||||
|
||||
@@ -10,6 +10,10 @@ namespace skydiveLogs_api.Data
|
||||
public LiteDbProvider(string connectionString)
|
||||
{
|
||||
_db = new LiteDatabase(connectionString);
|
||||
BsonMapper.Global.Entity<Jump>().DbRef(x => x.JumpType, "JumpType");
|
||||
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");
|
||||
}
|
||||
|
||||
public LiteCollection<T> GetCollection<T>()
|
||||
|
||||
@@ -6,13 +6,21 @@ namespace skydiveLogs_api.Model
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int JumpTypeId { get; set; }
|
||||
//public int JumpTypeId { get; set; }
|
||||
|
||||
public int AircraftId { get; set; }
|
||||
//public int AircraftId { get; set; }
|
||||
|
||||
public int DropZoneId { get; set; }
|
||||
//public int DropZoneId { get; set; }
|
||||
|
||||
public int GearId { get; set; }
|
||||
//public int GearId { get; set; }
|
||||
|
||||
public JumpType JumpType { get; set; }
|
||||
|
||||
public Aircraft Aircraft { get; set; }
|
||||
|
||||
public DropZone DropZone { get; set; }
|
||||
|
||||
public Gear Gear { get; set; }
|
||||
|
||||
public int ExitAltitude { get; set; }
|
||||
|
||||
|
||||
11
Back/skydiveLogs-api/DataContract/GearReq.cs
Normal file
11
Back/skydiveLogs-api/DataContract/GearReq.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace skydiveLogs_api.DataContract
|
||||
{
|
||||
public class GearReq
|
||||
{
|
||||
}
|
||||
}
|
||||
9
Back/skydiveLogs-api/DataContract/GearResp.cs
Normal file
9
Back/skydiveLogs-api/DataContract/GearResp.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace skydiveLogs_api.DataContract
|
||||
{
|
||||
public class GearResp
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,13 @@ namespace skydiveLogs_api.DataContract
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int JumpTypeId { get; set; }
|
||||
public JumpTypeResp JumpType { get; set; }
|
||||
|
||||
public int AircraftId { get; set; }
|
||||
public AircraftResp Aircraft { get; set; }
|
||||
|
||||
public int DropZoneId { get; set; }
|
||||
public DropZoneResp DropZone { get; set; }
|
||||
|
||||
public int GearId { get; set; }
|
||||
public GearResp Gear { get; set; }
|
||||
|
||||
public int ExitAltitude { get; set; }
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace skydiveLogs_api.Mapper
|
||||
{
|
||||
@@ -13,7 +10,9 @@ namespace skydiveLogs_api.Mapper
|
||||
CreateMap<DataContract.JumpTypeReq, Model.JumpType>();
|
||||
CreateMap<DataContract.AircraftReq, Model.Aircraft>();
|
||||
CreateMap<DataContract.DropZoneReq, Model.DropZone>();
|
||||
CreateMap<DataContract.GearReq, Model.Gear>();
|
||||
|
||||
CreateMap<Model.Gear, DataContract.GearResp>();
|
||||
CreateMap<Model.Jump, DataContract.JumpResp>();
|
||||
CreateMap<Model.JumpType ,DataContract.JumpTypeResp>();
|
||||
CreateMap<Model.Aircraft ,DataContract.AircraftResp>();
|
||||
|
||||
Reference in New Issue
Block a user