This commit is contained in:
Sébastien André
2020-03-04 22:47:43 +01:00
parent 3ac1e67c74
commit 848fdc6b5f
5 changed files with 43 additions and 18 deletions

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Cors;
using AutoMapper;
@@ -23,6 +24,7 @@ namespace skydiveLogs_api.Controllers
// GET: api/Gear
[HttpGet]
[EnableCors]
public IEnumerable<GearResp> Get()
{
var result = _gearService.GetAllGears();
@@ -31,6 +33,7 @@ namespace skydiveLogs_api.Controllers
// GET: api/Gear/5
[HttpGet("{id}")]
[EnableCors]
public GearResp Get(int id)
{
var result = _gearService.GetGearById(id);
@@ -39,6 +42,7 @@ namespace skydiveLogs_api.Controllers
// POST: api/Gear
[HttpPost]
[EnableCors]
public void Post([FromBody] GearReq value)
{
_gearService.AddNewGear(_mapper.Map<Gear>(value));
@@ -46,6 +50,7 @@ namespace skydiveLogs_api.Controllers
// PUT: api/Gear/5
[HttpPut("{id}")]
[EnableCors]
public void Put(int id, [FromBody] GearReq value)
{
_gearService.UpdateGear(id, _mapper.Map<Gear>(value));
@@ -53,6 +58,7 @@ namespace skydiveLogs_api.Controllers
// DELETE: api/ApiWithActions/5
[HttpDelete("{id}")]
[EnableCors]
public void Delete(int id)
{
_gearService.DeleteGearById(id);