using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using UniVerse.Application.DTOs.Achievements; using UniVerse.Application.Interfaces; namespace UniVerse.Api.Controllers; [ApiController] [Route("api/v1/achievements")] [Authorize] public class AchievementsController : ControllerBase { private readonly IAchievementService _achievements; public AchievementsController(IAchievementService achievements) => _achievements = achievements; [HttpGet] public async Task GetAll() => Ok(await _achievements.GetAllAsync()); [HttpGet("{id:int}")] public async Task> Get(int id) => Ok(await _achievements.GetByIdAsync(id)); [Authorize(Roles = "Admin")] [HttpPost] public async Task> Create([FromBody] CreateAchievementRequest req) => CreatedAtAction(nameof(Get), new { id = 0 }, await _achievements.CreateAsync(req)); [Authorize(Roles = "Admin")] [HttpPut("{id:int}")] public async Task> Update(int id, [FromBody] UpdateAchievementRequest req) => Ok(await _achievements.UpdateAsync(id, req)); [Authorize(Roles = "Admin")] [HttpDelete("{id:int}")] public async Task Delete(int id) { await _achievements.DeleteAsync(id); return NoContent(); } }