Add some update
Add a TODO for the ideas
This commit is contained in:
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public string InTunnel { get; set; }
|
||||||
|
|
||||||
#endregion Public Properties
|
#endregion Public Properties
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
21
Back/skydiveLogs-api.Domain/TunnelFlight.cs
Normal file
21
Back/skydiveLogs-api.Domain/TunnelFlight.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace skydiveLogs_api.Domain
|
||||||
|
{
|
||||||
|
public class TunnelFlight
|
||||||
|
{
|
||||||
|
#region Public Properties
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public Tunnel Tunnel { get; set; }
|
||||||
|
|
||||||
|
public int NbMinutes { get; set; }
|
||||||
|
|
||||||
|
public string Notes { get; set; }
|
||||||
|
|
||||||
|
public DateTime FlightDate { get; set; }
|
||||||
|
|
||||||
|
#endregion Public Properties
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,8 @@ namespace skydiveLogs_api.DomainBusiness.Interfaces
|
|||||||
|
|
||||||
Tunnel GetTunnelById(int id);
|
Tunnel GetTunnelById(int id);
|
||||||
|
|
||||||
|
void AddNewFlight(int tunnelId, TunnelFlight newFlight);
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,9 +12,13 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
#region Public Constructors
|
#region Public Constructors
|
||||||
|
|
||||||
public TunnelService(IDropZoneRepository dropZoneRepository,
|
public TunnelService(IDropZoneRepository dropZoneRepository,
|
||||||
|
ITunnelFlightepository tunnelFlightRepository,
|
||||||
|
IDropZoneService dropZoneService,
|
||||||
ICacheService cacheService)
|
ICacheService cacheService)
|
||||||
{
|
{
|
||||||
_dropZoneRepository = dropZoneRepository;
|
_dropZoneRepository = dropZoneRepository;
|
||||||
|
_dropZoneService = dropZoneService;
|
||||||
|
_tunnelFlightRepository = tunnelFlightRepository;
|
||||||
_cacheService = cacheService;
|
_cacheService = cacheService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,6 +37,28 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
return allTunnels.Single(g => g.Id == id);
|
return allTunnels.Single(g => g.Id == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddNewFlight(int tunnelId, TunnelFlight newFlight)
|
||||||
|
{
|
||||||
|
var selectedTunnel = _dropZoneService.GetDzById(tunnelId)
|
||||||
|
.Single(t => new Tunnel
|
||||||
|
{
|
||||||
|
Id = t.Id,
|
||||||
|
Name = t.Name,
|
||||||
|
Website = t.Website,
|
||||||
|
Address = t.Address,
|
||||||
|
Email = t.Email,
|
||||||
|
Latitude = t.Latitude,
|
||||||
|
Longitude = t.Longitude
|
||||||
|
}); ;
|
||||||
|
|
||||||
|
newFlight.Tunnel = selectedTunnel;
|
||||||
|
_tunnelFlightRepository.Add(newFlight);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
|
||||||
|
#region Private Methods
|
||||||
|
|
||||||
private IEnumerable<Tunnel> GetAllRefTunnels()
|
private IEnumerable<Tunnel> GetAllRefTunnels()
|
||||||
{
|
{
|
||||||
if (!_cacheService.Contains(CacheType.Tunnel))
|
if (!_cacheService.Contains(CacheType.Tunnel))
|
||||||
@@ -54,13 +80,14 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
|
|
||||||
return _cacheService.Get<IEnumerable<Tunnel>>(CacheType.Tunnel);
|
return _cacheService.Get<IEnumerable<Tunnel>>(CacheType.Tunnel);
|
||||||
}
|
}
|
||||||
|
#endregion Private Methods
|
||||||
#endregion Public Methods
|
|
||||||
|
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
|
||||||
private readonly ICacheService _cacheService;
|
private readonly ICacheService _cacheService;
|
||||||
|
private readonly IDropZoneService _dropZoneService;
|
||||||
private readonly IDropZoneRepository _dropZoneRepository;
|
private readonly IDropZoneRepository _dropZoneRepository;
|
||||||
|
private readonly ITunnelFlightepository _tunnelFlightRepository;
|
||||||
|
|
||||||
#endregion Private Fields
|
#endregion Private Fields
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,14 +21,21 @@ namespace skydiveLogs_api.Infrastructure.Interfaces
|
|||||||
ILiteCollection<DropZone> CollOfDropZone { get; }
|
ILiteCollection<DropZone> CollOfDropZone { get; }
|
||||||
|
|
||||||
ILiteCollection<FavoriteDropZone> CollOfFavoriteDropZone { get; }
|
ILiteCollection<FavoriteDropZone> CollOfFavoriteDropZone { get; }
|
||||||
|
|
||||||
ILiteCollection<Gear> CollOfGear { get; }
|
ILiteCollection<Gear> CollOfGear { get; }
|
||||||
|
|
||||||
ILiteCollection<UserImage> CollOfImage { get; }
|
ILiteCollection<UserImage> CollOfImage { get; }
|
||||||
|
|
||||||
ILiteCollection<Jump> CollOfJump { get; }
|
ILiteCollection<Jump> CollOfJump { get; }
|
||||||
|
|
||||||
ILiteCollection<JumpType> CollOfJumpType { get; }
|
ILiteCollection<JumpType> CollOfJumpType { get; }
|
||||||
|
|
||||||
ILiteCollection<UserStats> CollOfStats { get; }
|
ILiteCollection<UserStats> CollOfStats { get; }
|
||||||
|
|
||||||
ILiteCollection<User> CollOfUser { get; }
|
ILiteCollection<User> CollOfUser { get; }
|
||||||
|
|
||||||
|
ILiteCollection<TunnelFlight> CollOfTunnelFlight { get; }
|
||||||
|
|
||||||
#endregion Public Properties
|
#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.User, "User");
|
||||||
BsonMapper.Global.Entity<FavoriteDropZone>().DbRef(x => x.DropZone, "DropZone");
|
BsonMapper.Global.Entity<FavoriteDropZone>().DbRef(x => x.DropZone, "DropZone");
|
||||||
|
|
||||||
|
BsonMapper.Global.Entity<TunnelFlight>().DbRef(x => x.Tunnel, "DropZone");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Constructors
|
#endregion Public Constructors
|
||||||
@@ -56,6 +58,7 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
public ILiteCollection<JumpType> CollOfJumpType => _db.GetCollection<JumpType>();
|
public ILiteCollection<JumpType> CollOfJumpType => _db.GetCollection<JumpType>();
|
||||||
public ILiteCollection<UserStats> CollOfStats => _db.GetCollection<UserStats>();
|
public ILiteCollection<UserStats> CollOfStats => _db.GetCollection<UserStats>();
|
||||||
public ILiteCollection<User> CollOfUser => _db.GetCollection<User>();
|
public ILiteCollection<User> CollOfUser => _db.GetCollection<User>();
|
||||||
|
public ILiteCollection<TunnelFlight> CollOfTunnelFlight => _db.GetCollection<TunnelFlight>();
|
||||||
|
|
||||||
#endregion Public Properties
|
#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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
using Microsoft.AspNetCore.Cors;
|
using Microsoft.AspNetCore.Cors;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using skydiveLogs_api.DataContract;
|
using skydiveLogs_api.DataContract;
|
||||||
|
using skydiveLogs_api.Domain;
|
||||||
using skydiveLogs_api.DomainBusiness.Interfaces;
|
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
@@ -49,12 +50,13 @@ namespace skydiveLogs_api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// POST: api/Tunnel
|
// POST: api/Tunnel
|
||||||
//[HttpPost]
|
[HttpPost]
|
||||||
//[EnableCors]
|
[EnableCors]
|
||||||
//public void Post([FromBody] TunnelReq value)
|
public void Post([FromBody] TunnelFlightReq value)
|
||||||
//{
|
{
|
||||||
// _tunnelService.AddNewJumpType(_mapper.Map<Tunnel>(value));
|
_tunnelService.AddNewFlight(value.TunnelId,
|
||||||
//}
|
_mapper.Map<TunnelFlight>(value));
|
||||||
|
}
|
||||||
|
|
||||||
// PUT: api/Tunnel/5
|
// PUT: api/Tunnel/5
|
||||||
//[HttpPut("{id}")]
|
//[HttpPut("{id}")]
|
||||||
|
|||||||
17
Back/skydiveLogs-api/DataContract/TunnelFlightReq.cs
Normal file
17
Back/skydiveLogs-api/DataContract/TunnelFlightReq.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace skydiveLogs_api.DataContract
|
||||||
|
{
|
||||||
|
public class TunnelFlightReq
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public int TunnelId { get; set; }
|
||||||
|
|
||||||
|
public int NbMinutes { get; set; }
|
||||||
|
|
||||||
|
public string Notes { get; set; }
|
||||||
|
|
||||||
|
public DateTime FlightDate { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace skydiveLogs_api.DataContract
|
|
||||||
{
|
|
||||||
public class TunnelReq
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
public string Latitude { get; set; }
|
|
||||||
|
|
||||||
public string Longitude { get; set; }
|
|
||||||
|
|
||||||
public string Name { get; set; }
|
|
||||||
|
|
||||||
public string Address { get; set; }
|
|
||||||
|
|
||||||
public string Website { get; set; }
|
|
||||||
|
|
||||||
public string Email { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,7 +17,7 @@ namespace skydiveLogs_api.Mapper
|
|||||||
CreateMap<DataContract.GearReq, Gear>();
|
CreateMap<DataContract.GearReq, Gear>();
|
||||||
CreateMap<DataContract.UserReq, User>();
|
CreateMap<DataContract.UserReq, User>();
|
||||||
CreateMap<DataContract.ImageReq, UserImage>();
|
CreateMap<DataContract.ImageReq, UserImage>();
|
||||||
CreateMap<DataContract.TunnelReq, Tunnel>();
|
CreateMap<DataContract.TunnelFlightReq, TunnelFlight>();
|
||||||
|
|
||||||
CreateMap<Gear, DataContract.GearResp>();
|
CreateMap<Gear, DataContract.GearResp>();
|
||||||
CreateMap<Jump, DataContract.JumpResp>().ForMember(dest => dest.AircraftId, opt => opt.MapFrom(s => s.Aircraft.Id))
|
CreateMap<Jump, DataContract.JumpResp>().ForMember(dest => dest.AircraftId, opt => opt.MapFrom(s => s.Aircraft.Id))
|
||||||
|
|||||||
11
TODO.md
Normal file
11
TODO.md
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
BACK :
|
||||||
|
- JumpType :
|
||||||
|
- ajouter l'indication que le type de saut est faisable en tunnel
|
||||||
|
|
||||||
|
FRONT :
|
||||||
|
- JumpType :
|
||||||
|
- ajouter dans la page un check-box pour indiquer que le type est faisable en tunnel
|
||||||
|
- permettre de mettre à jour le type sur l'info "en tunnel"
|
||||||
|
- Tunnel Flight
|
||||||
|
- la liste de type de vol filter pour ceux concernant par le tunnel
|
||||||
|
- avec juste 1 date
|
||||||
Reference in New Issue
Block a user