Add controler actions to return stats for

the current season
This commit is contained in:
Sébastien André
2020-02-14 16:48:43 +01:00
parent b8a1115d6a
commit 6e804b1ae4
5 changed files with 132 additions and 0 deletions

View File

@@ -66,6 +66,34 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
[HttpGet("ForLastYear")]
[EnableCors]
public StatisticForLastYearResp ForLastYear()
{
var resultByDz = _statsService.GetStatsForLastYearByDz();
var resultByJumpType = _statsService.GetStatsForLastYearByJumpType();
var result = new StatisticForLastYearResp();
result.ByDz = _mapper.Map<IEnumerable<StatisticResp>>(resultByDz);
result.ByJumpType = _mapper.Map<IEnumerable<StatisticResp>>(resultByJumpType);
return result;
}
[HttpGet("ForLastMonth")]
[EnableCors]
public StatisticForLastMonthResp ForLastMonth()
{
var resultByDz = _statsService.GetStatsForLastMonthByDz();
var resultByJumpType = _statsService.GetStatsForLastMonthByJumpType();
var result = new StatisticForLastMonthResp();
result.ByDz = _mapper.Map<IEnumerable<StatisticResp>>(resultByDz);
result.ByJumpType = _mapper.Map<IEnumerable<StatisticResp>>(resultByJumpType);
return result;
}
#region Private properties
private readonly IStatsService _statsService;

View File

@@ -0,0 +1,11 @@
using System.Collections.Generic;
namespace skydiveLogs_api.DataContract
{
public class StatisticForLastMonthResp
{
public IEnumerable<StatisticResp> ByDz { get; set; }
public IEnumerable<StatisticResp> ByJumpType { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
using System.Collections.Generic;
namespace skydiveLogs_api.DataContract
{
public class StatisticForLastYearResp
{
public IEnumerable<StatisticResp> ByDz { get; set; }
public IEnumerable<StatisticResp> ByJumpType { get; set; }
}
}