Add CRUD operations on exercices template (catalog svc)

dev
Leo TUAILLON 2 weeks ago
parent 4dc203b705
commit 143ba29d60

@ -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);

@ -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; }

Loading…
Cancel
Save