Add a cache system on the referential info

+ Add an identity service
This commit is contained in:
Sébastien André
2021-04-17 22:17:45 +02:00
parent 0bb9ed2a30
commit 143127cd01
30 changed files with 955 additions and 570 deletions

View File

@@ -1,17 +1,16 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using AutoMapper;
using Microsoft.AspNetCore.Cors;
using AutoMapper;
using skydiveLogs_api.DomainBusiness.Interfaces;
using Microsoft.AspNetCore.Mvc;
using skydiveLogs_api.DataContract;
using skydiveLogs_api.DomainBusiness.Interfaces;
using System.Collections.Generic;
namespace skydiveLogs_api.Controllers
{
public class StatsController : Base
{
#region Public Constructors
public StatsController(IStatsService statsService,
IMapper mapper)
{
@@ -19,38 +18,24 @@ namespace skydiveLogs_api.Controllers
_mapper = mapper;
}
[HttpGet("Simple")]
[EnableCors]
public SimpleSummaryResp Simple()
{
var result = _statsService.GetSimpleSummary(ConnectedUser);
#endregion Public Constructors
return _mapper.Map<SimpleSummaryResp>(result);
#region Public Methods
[HttpGet("ByAircraft")]
[EnableCors]
public IEnumerable<StatisticResp> ByAircraft()
{
var result = _statsService.GetStatsByAircraft();
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
[HttpGet("ByDz")]
[EnableCors]
public IEnumerable<StatisticResp> ByDz()
{
var result = _statsService.GetStatsByDz(ConnectedUser);
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
[HttpGet("ByAircraft")]
[EnableCors]
public IEnumerable<StatisticResp> ByAircraft()
{
var result = _statsService.GetStatsByAircraft(ConnectedUser);
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
[HttpGet("ByJumpType")]
[EnableCors]
public IEnumerable<StatisticResp> ByJumpType()
{
var result = _statsService.GetStatsByJumpType(ConnectedUser);
var result = _statsService.GetStatsByDz();
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
@@ -59,7 +44,16 @@ namespace skydiveLogs_api.Controllers
[EnableCors]
public IEnumerable<StatisticResp> ByGear()
{
var result = _statsService.GetStatsByGear(ConnectedUser);
var result = _statsService.GetStatsByGear();
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
[HttpGet("ByJumpType")]
[EnableCors]
public IEnumerable<StatisticResp> ByJumpType()
{
var result = _statsService.GetStatsByJumpType();
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
@@ -68,31 +62,17 @@ namespace skydiveLogs_api.Controllers
[EnableCors]
public IEnumerable<StatisticResp> ByYear()
{
var result = _statsService.GetStatsByYear(ConnectedUser);
var result = _statsService.GetStatsByYear();
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
[HttpGet("ForLastYear")]
[EnableCors]
public StatisticForLastYearResp ForLastYear()
{
var resultByDz = _statsService.GetStatsForLastYearByDz(ConnectedUser);
var resultByJumpType = _statsService.GetStatsForLastYearByJumpType(ConnectedUser);
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(ConnectedUser);
var resultByJumpType = _statsService.GetStatsForLastMonthByJumpType(ConnectedUser);
var resultByDz = _statsService.GetStatsForLastMonthByDz();
var resultByJumpType = _statsService.GetStatsForLastMonthByJumpType();
var result = new StatisticForLastMonthResp();
result.ByDz = _mapper.Map<IEnumerable<StatisticResp>>(resultByDz);
@@ -101,10 +81,36 @@ namespace skydiveLogs_api.Controllers
return 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("Simple")]
[EnableCors]
public SimpleSummaryResp Simple()
{
var result = _statsService.GetSimpleSummary();
return _mapper.Map<SimpleSummaryResp>(result);
}
#endregion Public Methods
#region Private properties
private readonly IStatsService _statsService;
private readonly IMapper _mapper;
#endregion
private readonly IStatsService _statsService;
#endregion Private properties
}
}
}