From a3b67ffb95cdcc3b54bc946ea1f4c83c5e2d9cc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Andr=C3=A9?= Date: Thu, 24 Oct 2019 18:16:25 +0200 Subject: [PATCH] Add a begining of Stats controler --- .../Controllers/StatsController.cs | 74 +++++++++++++++++++ Back/skydiveLogs-api/Startup.cs | 3 +- 2 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 Back/skydiveLogs-api/Controllers/StatsController.cs diff --git a/Back/skydiveLogs-api/Controllers/StatsController.cs b/Back/skydiveLogs-api/Controllers/StatsController.cs new file mode 100644 index 0000000..5e97d96 --- /dev/null +++ b/Back/skydiveLogs-api/Controllers/StatsController.cs @@ -0,0 +1,74 @@ +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Cors; + +using AutoMapper; + +using skydiveLogs_api.Business.Interface; +using skydiveLogs_api.DataContract; +using skydiveLogs_api.Model; + + +namespace skydiveLogs_api.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class StatsController : ControllerBase + { + public StatsController(IDropZoneService dropZoneService, + IMapper mapper) + { + _dropZoneService = dropZoneService; + _mapper = mapper; + } + + [HttpGet("ByDz")] + [EnableCors] + public IEnumerable ByDz() + { + var result = _dropZoneService.GetAllDzs(); + + return _mapper.Map>(result); + } + + [HttpGet("ByAircraft")] + [EnableCors] + public IEnumerable ByAircraft() + { + var result = _dropZoneService.GetAllDzs(); + + return _mapper.Map>(result); + } + + [HttpGet("ByJumpType")] + [EnableCors] + public IEnumerable ByJumpType() + { + var result = _dropZoneService.GetAllDzs(); + + return _mapper.Map>(result); + } + + [HttpGet("ByRig")] + [EnableCors] + public IEnumerable ByRig() + { + var result = _dropZoneService.GetAllDzs(); + + return _mapper.Map>(result); + } + + [HttpGet("ByYear")] + [EnableCors] + public IEnumerable ByYear() + { + var result = _dropZoneService.GetAllDzs(); + + return _mapper.Map>(result); + } + + + private readonly IDropZoneService _dropZoneService; + private readonly IMapper _mapper; + } +} diff --git a/Back/skydiveLogs-api/Startup.cs b/Back/skydiveLogs-api/Startup.cs index 4efc58b..b21532c 100644 --- a/Back/skydiveLogs-api/Startup.cs +++ b/Back/skydiveLogs-api/Startup.cs @@ -25,7 +25,6 @@ namespace skydiveLogs_api // CORS services.AddCors(options => { - //options.AddPolicy(MyAllowSpecificOrigins, options.AddDefaultPolicy( builder => { @@ -55,7 +54,7 @@ namespace skydiveLogs_api app.UseHsts(); } - app.UseCors(); // (MyAllowSpecificOrigins); + app.UseCors(); //app.UseHttpsRedirection(); app.UseMvc();