using System.Collections.Generic; using System.Threading.Tasks; using AutoMapper; using LaDOSE.Business.Interface; using LaDOSE.DTO; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace LaDOSE.Api.Controllers { [Authorize] [Produces("application/json")] [Route("api/[controller]")] public class StatisticsController : Controller { private readonly IStatisticsService _service; private readonly IMapper _mapper; public StatisticsController(IMapper mapper, IStatisticsService service) { _mapper = mapper; _service = service; } /// /// Match statistics for the given Event ids. Body is a bare JSON array of ids, /// like TournamentController.GetResults. /// A null or empty array returns a zeroed, empty MatchStatsDTO rather than an error. /// Read Coverage before trusting the numbers: many brackets have no set rows at all. /// [HttpPost("Matches")] public async Task GetMatchStats([FromBody] List ids) { var stats = await _service.GetMatchStats(ids); return _mapper.Map(stats); } } }