From 143ba29d6047a8bcacc81fd809194d732ebc9a26 Mon Sep 17 00:00:00 2001 From: tleodev Date: Wed, 21 May 2025 19:58:16 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9E=95=20Add=20CRUD=20operations=20on=20exer?= =?UTF-8?q?cices=20template=20(catalog=20svc)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CatalogService/Controllers/ExercicesController.cs | 8 +++++++- src/CatalogService/DTOs/UpdateExerciceTemplateDto.cs | 3 --- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/CatalogService/Controllers/ExercicesController.cs b/src/CatalogService/Controllers/ExercicesController.cs index deb6456..5370499 100644 --- a/src/CatalogService/Controllers/ExercicesController.cs +++ b/src/CatalogService/Controllers/ExercicesController.cs @@ -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 Create([FromBody] CreateExerciceTemplateDto dto) { var exercice = _mapper.Map(dto); @@ -31,6 +34,7 @@ public class ExercicesController : ControllerBase } [HttpPut("{id}")] + [AllowAnonymous] public async Task 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 Delete(string id) { var exercice = await _context.Exercices.FindAsync(id); @@ -54,6 +59,7 @@ public class ExercicesController : ControllerBase } [HttpGet("{id}")] + [AllowAnonymous] public async Task> GetById(string id) { var exercice = await _context.Exercices.FindAsync(id); diff --git a/src/CatalogService/DTOs/UpdateExerciceTemplateDto.cs b/src/CatalogService/DTOs/UpdateExerciceTemplateDto.cs index e19a600..0031442 100644 --- a/src/CatalogService/DTOs/UpdateExerciceTemplateDto.cs +++ b/src/CatalogService/DTOs/UpdateExerciceTemplateDto.cs @@ -5,9 +5,6 @@ namespace CatalogService.DTOs; public class UpdateExerciceTemplateDto { - [Required] - public required string Id { get; set; } - public string? Name { get; set; } public string? Description { get; set; }