Add a begining of Stats controler
This commit is contained in:
74
Back/skydiveLogs-api/Controllers/StatsController.cs
Normal file
74
Back/skydiveLogs-api/Controllers/StatsController.cs
Normal file
@@ -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<DropZoneResp> ByDz()
|
||||||
|
{
|
||||||
|
var result = _dropZoneService.GetAllDzs();
|
||||||
|
|
||||||
|
return _mapper.Map<IEnumerable<DropZoneResp>>(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("ByAircraft")]
|
||||||
|
[EnableCors]
|
||||||
|
public IEnumerable<DropZoneResp> ByAircraft()
|
||||||
|
{
|
||||||
|
var result = _dropZoneService.GetAllDzs();
|
||||||
|
|
||||||
|
return _mapper.Map<IEnumerable<DropZoneResp>>(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("ByJumpType")]
|
||||||
|
[EnableCors]
|
||||||
|
public IEnumerable<DropZoneResp> ByJumpType()
|
||||||
|
{
|
||||||
|
var result = _dropZoneService.GetAllDzs();
|
||||||
|
|
||||||
|
return _mapper.Map<IEnumerable<DropZoneResp>>(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("ByRig")]
|
||||||
|
[EnableCors]
|
||||||
|
public IEnumerable<DropZoneResp> ByRig()
|
||||||
|
{
|
||||||
|
var result = _dropZoneService.GetAllDzs();
|
||||||
|
|
||||||
|
return _mapper.Map<IEnumerable<DropZoneResp>>(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("ByYear")]
|
||||||
|
[EnableCors]
|
||||||
|
public IEnumerable<DropZoneResp> ByYear()
|
||||||
|
{
|
||||||
|
var result = _dropZoneService.GetAllDzs();
|
||||||
|
|
||||||
|
return _mapper.Map<IEnumerable<DropZoneResp>>(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private readonly IDropZoneService _dropZoneService;
|
||||||
|
private readonly IMapper _mapper;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,7 +25,6 @@ namespace skydiveLogs_api
|
|||||||
// CORS
|
// CORS
|
||||||
services.AddCors(options =>
|
services.AddCors(options =>
|
||||||
{
|
{
|
||||||
//options.AddPolicy(MyAllowSpecificOrigins,
|
|
||||||
options.AddDefaultPolicy(
|
options.AddDefaultPolicy(
|
||||||
builder =>
|
builder =>
|
||||||
{
|
{
|
||||||
@@ -55,7 +54,7 @@ namespace skydiveLogs_api
|
|||||||
app.UseHsts();
|
app.UseHsts();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseCors(); // (MyAllowSpecificOrigins);
|
app.UseCors();
|
||||||
|
|
||||||
//app.UseHttpsRedirection();
|
//app.UseHttpsRedirection();
|
||||||
app.UseMvc();
|
app.UseMvc();
|
||||||
|
|||||||
Reference in New Issue
Block a user