Files
SkydiveLogs/Back/skydiveLogs-api/Controllers/StatsController.cs
2020-01-29 14:24:04 +01:00

76 lines
1.9 KiB
C#

using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Cors;
using AutoMapper;
using skydiveLogs_api.Business.Interface;
using skydiveLogs_api.DataContract;
namespace skydiveLogs_api.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class StatsController : ControllerBase
{
public StatsController(IStatsService statsService,
IMapper mapper)
{
_statsService = statsService;
_mapper = mapper;
}
[HttpGet("ByDz")]
[EnableCors]
public IEnumerable<StatisticResp> ByDz()
{
var result = _statsService.GetStatsByDz();
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
[HttpGet("ByAircraft")]
[EnableCors]
public IEnumerable<StatisticResp> ByAircraft()
{
var result = _statsService.GetStatsByAircraft();
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
[HttpGet("ByJumpType")]
[EnableCors]
public IEnumerable<StatisticResp> ByJumpType()
{
var result = _statsService.GetStatsByJumpType();
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
[HttpGet("ByGear")]
[EnableCors]
public IEnumerable<StatisticResp> ByGear()
{
var result = _statsService.GetStatsByGear();
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
[HttpGet("ByYear")]
[EnableCors]
public IEnumerable<StatisticResp> ByYear()
{
var result = _statsService.GetStatsByYear();
return _mapper.Map<IEnumerable<StatisticResp>>(result);
}
#region Private properties
private readonly IStatsService _statsService;
private readonly IMapper _mapper;
#endregion
}
}