|
|
|
@ -2,6 +2,7 @@ using AutoMapper;
|
|
|
|
|
using CatalogService.Data;
|
|
|
|
|
using CatalogService.DTOs;
|
|
|
|
|
using CatalogService.Entities;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using Shared.DTOs;
|
|
|
|
@ -9,7 +10,8 @@ using Shared.DTOs;
|
|
|
|
|
namespace CatalogService.Controllers;
|
|
|
|
|
|
|
|
|
|
[ApiController]
|
|
|
|
|
[Route("api/[controller]")]
|
|
|
|
|
[Authorize]
|
|
|
|
|
[Route("api/catalog/[controller]")]
|
|
|
|
|
public class ExercicesController : ControllerBase
|
|
|
|
|
{
|
|
|
|
|
private readonly CatalogDbContext _context;
|
|
|
|
@ -22,6 +24,7 @@ public class ExercicesController : ControllerBase
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
public async Task<IActionResult> Create([FromBody] CreateExerciceTemplateDto dto)
|
|
|
|
|
{
|
|
|
|
|
var exercice = _mapper.Map<Exercice>(dto);
|
|
|
|
@ -31,6 +34,7 @@ public class ExercicesController : ControllerBase
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPut("{id}")]
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
public async Task<IActionResult> Update(string id, [FromBody] UpdateExerciceTemplateDto dto)
|
|
|
|
|
{
|
|
|
|
|
var exercice = await _context.Exercices.FindAsync(id);
|
|
|
|
@ -43,6 +47,7 @@ public class ExercicesController : ControllerBase
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpDelete("{id}")]
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
public async Task<IActionResult> Delete(string id)
|
|
|
|
|
{
|
|
|
|
|
var exercice = await _context.Exercices.FindAsync(id);
|
|
|
|
@ -54,6 +59,7 @@ public class ExercicesController : ControllerBase
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet("{id}")]
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
public async Task<ActionResult<ExerciceTemplateDto>> GetById(string id)
|
|
|
|
|
{
|
|
|
|
|
var exercice = await _context.Exercices.FindAsync(id);
|
|
|
|
|