Ajout de l'implémentation des stats par dz, avion, piège et annèe.

This commit is contained in:
Sébastien André
2019-10-25 15:05:57 +02:00
parent e8dacaaefe
commit 6499e03c56
11 changed files with 159 additions and 25 deletions

View File

@@ -6,7 +6,6 @@ using AutoMapper;
using skydiveLogs_api.Business.Interface;
using skydiveLogs_api.DataContract;
using skydiveLogs_api.Model;
namespace skydiveLogs_api.Controllers
@@ -15,60 +14,62 @@ namespace skydiveLogs_api.Controllers
[ApiController]
public class StatsController : ControllerBase
{
public StatsController(IDropZoneService dropZoneService,
public StatsController(IStatsService statsService,
IMapper mapper)
{
_dropZoneService = dropZoneService;
_statsService = statsService;
_mapper = mapper;
}
[HttpGet("ByDz")]
[EnableCors]
public IEnumerable<DropZoneResp> ByDz()
public IEnumerable<StatisticResp> ByDz()
{
var result = _dropZoneService.GetAllDzs();
var result = _statsService.GetStatsByDz();
return _mapper.Map<IEnumerable<DropZoneResp>>(result);
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
[HttpGet("ByAircraft")]
[EnableCors]
public IEnumerable<DropZoneResp> ByAircraft()
public IEnumerable<StatisticResp> ByAircraft()
{
var result = _dropZoneService.GetAllDzs();
var result = _statsService.GetStatsByAircraft();
return _mapper.Map<IEnumerable<DropZoneResp>>(result);
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
[HttpGet("ByJumpType")]
[EnableCors]
public IEnumerable<DropZoneResp> ByJumpType()
public IEnumerable<StatisticResp> ByJumpType()
{
var result = _dropZoneService.GetAllDzs();
var result = _statsService.GetStatsByJumpType();
return _mapper.Map<IEnumerable<DropZoneResp>>(result);
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
[HttpGet("ByRig")]
[EnableCors]
public IEnumerable<DropZoneResp> ByRig()
public IEnumerable<StatisticResp> ByRig()
{
var result = _dropZoneService.GetAllDzs();
var result = _statsService.GetStatsByRig();
return _mapper.Map<IEnumerable<DropZoneResp>>(result);
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
[HttpGet("ByYear")]
[EnableCors]
public IEnumerable<DropZoneResp> ByYear()
public IEnumerable<StatisticResp> ByYear()
{
var result = _dropZoneService.GetAllDzs();
var result = _statsService.GetStatsByYear();
return _mapper.Map<IEnumerable<DropZoneResp>>(result);
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
#region Private properties
private readonly IStatsService _statsService;
private readonly IDropZoneService _dropZoneService;
private readonly IMapper _mapper;
#endregion
}
}