Add function to get the tunnel flights between dates
This commit is contained in:
@@ -15,6 +15,8 @@ namespace skydiveLogs_api.DomainBusiness.Interfaces
|
|||||||
|
|
||||||
IEnumerable<TunnelFlight> GetTunnelFlightsByIndexes(int beginIndex, int endIndex);
|
IEnumerable<TunnelFlight> GetTunnelFlightsByIndexes(int beginIndex, int endIndex);
|
||||||
|
|
||||||
|
IEnumerable<TunnelFlight> GetTunnelFlightByDates(string beginDate, string endDate);
|
||||||
|
|
||||||
void AddNewFlight(int tunnelId, TunnelFlight newFlight);
|
void AddNewFlight(int tunnelId, TunnelFlight newFlight);
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using skydiveLogs_api.Domain;
|
using skydiveLogs_api.Domain;
|
||||||
using skydiveLogs_api.DomainBusiness.Interfaces;
|
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||||
using skydiveLogs_api.DomainService.Repositories;
|
using skydiveLogs_api.DomainService.Repositories;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace skydiveLogs_api.DomainBusiness
|
namespace skydiveLogs_api.DomainBusiness
|
||||||
@@ -60,6 +61,15 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
return _tunnelFlightRepository.GetBetweenIndex(_identityService.ConnectedUser, beginIndex, endIndex);
|
return _tunnelFlightRepository.GetBetweenIndex(_identityService.ConnectedUser, beginIndex, endIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<TunnelFlight> GetTunnelFlightByDates(string beginDate, string endDate)
|
||||||
|
{
|
||||||
|
var convertedBeginDate = Convert.ToDateTime(beginDate);
|
||||||
|
var convertedEndDate = Convert.ToDateTime(endDate);
|
||||||
|
|
||||||
|
return _tunnelFlightRepository.GetBetweenDate(_identityService.ConnectedUser, convertedBeginDate, convertedEndDate);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
|
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using skydiveLogs_api.Domain;
|
using skydiveLogs_api.Domain;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace skydiveLogs_api.DomainService.Repositories
|
namespace skydiveLogs_api.DomainService.Repositories
|
||||||
@@ -11,6 +12,8 @@ namespace skydiveLogs_api.DomainService.Repositories
|
|||||||
|
|
||||||
IEnumerable<TunnelFlight> GetBetweenIndex(User user, int beginIndex, int endIndex);
|
IEnumerable<TunnelFlight> GetBetweenIndex(User user, int beginIndex, int endIndex);
|
||||||
|
|
||||||
|
IEnumerable<TunnelFlight> GetBetweenDate(User user, DateTime beginDate, DateTime endDate);
|
||||||
|
|
||||||
int GetCount(User user);
|
int GetCount(User user);
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using skydiveLogs_api.Domain;
|
using skydiveLogs_api.Domain;
|
||||||
using skydiveLogs_api.DomainService.Repositories;
|
using skydiveLogs_api.DomainService.Repositories;
|
||||||
using skydiveLogs_api.Infrastructure.Interfaces;
|
using skydiveLogs_api.Infrastructure.Interfaces;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace skydiveLogs_api.Infrastructure
|
namespace skydiveLogs_api.Infrastructure
|
||||||
@@ -64,6 +65,16 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<TunnelFlight> GetBetweenDate(User user, DateTime beginDate, DateTime endDate)
|
||||||
|
{
|
||||||
|
return _col.Include(x => x.Tunnel)
|
||||||
|
.Query()
|
||||||
|
.OrderByDescending(j => j.FlightDate)
|
||||||
|
.Where(j => j.FlightDate >= beginDate)
|
||||||
|
.Where(j => j.FlightDate <= endDate)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
public TunnelFlight GetById(int id)
|
public TunnelFlight GetById(int id)
|
||||||
{
|
{
|
||||||
return _col.FindById(new BsonValue(id));
|
return _col.FindById(new BsonValue(id));
|
||||||
|
|||||||
@@ -49,6 +49,15 @@ namespace skydiveLogs_api.Controllers
|
|||||||
return _mapper.Map<TunnelFlightResp>(result);
|
return _mapper.Map<TunnelFlightResp>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GET: api/TunnelFlight/20230101/20230701
|
||||||
|
[HttpGet("{beginDate}/{endDate}")]
|
||||||
|
[EnableCors]
|
||||||
|
public TunnelFlightResp Get(string beginDate, string endDate)
|
||||||
|
{
|
||||||
|
var result = _tunnelFlightService.GetTunnelFlightByDates(beginDate, endDate);
|
||||||
|
return _mapper.Map<TunnelFlightResp>(result);
|
||||||
|
}
|
||||||
|
|
||||||
// POST: api/Tunnel
|
// POST: api/Tunnel
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[EnableCors]
|
[EnableCors]
|
||||||
|
|||||||
Reference in New Issue
Block a user