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
}
}

View File

@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace skydiveLogs_api.DataContract
{
@@ -24,5 +21,7 @@ namespace skydiveLogs_api.DataContract
public bool WithCutaway { get; set; }
public string Notes { get; set; }
public DateTime JumpDate { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace skydiveLogs_api.DataContract
{
public class StatisticResp
{
public string Label { get; set; }
public int Nb { get; set; }
}
}

View File

@@ -18,6 +18,7 @@ namespace skydiveLogs_api.Mapper
CreateMap<Model.JumpType ,DataContract.JumpTypeResp>();
CreateMap<Model.Aircraft ,DataContract.AircraftResp>();
CreateMap<Model.DropZone ,DataContract.DropZoneResp>();
CreateMap<Model.Statistic ,DataContract.StatisticResp>();
}
}
}