You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.5 KiB
60 lines
1.5 KiB
|
2 weeks ago
|
using Build_God_Api.Common;
|
||
|
|
using Build_God_Api.DB;
|
||
|
|
using Build_God_Api.Services;
|
||
|
|
using Microsoft.AspNetCore.Authorization;
|
||
|
|
using Microsoft.AspNetCore.Mvc;
|
||
|
|
|
||
|
|
namespace Build_God_Api.Controllers
|
||
|
|
{
|
||
|
|
[ApiController]
|
||
|
|
[Route("api/god/[controller]")]
|
||
|
|
public class PillController(IPillService service) : ControllerBase
|
||
|
|
{
|
||
|
|
private readonly IPillService service = service;
|
||
|
|
|
||
|
|
[HttpPost]
|
||
|
|
[Authorize(Roles = "admin")]
|
||
|
|
public async Task<ActionResult<bool>> Add([FromBody] Pill item)
|
||
|
|
{
|
||
|
|
return await service.Add(item);
|
||
|
|
}
|
||
|
|
|
||
|
|
[HttpDelete("{id}")]
|
||
|
|
[Authorize(Roles = "admin")]
|
||
|
|
public async Task<ActionResult<bool>> Delete(int id)
|
||
|
|
{
|
||
|
|
return await service.Delete(id);
|
||
|
|
}
|
||
|
|
|
||
|
|
[HttpPut]
|
||
|
|
[Authorize(Roles = "admin")]
|
||
|
|
public async Task<ActionResult<bool>> Update([FromBody] Pill item)
|
||
|
|
{
|
||
|
|
return await service.Update(item);
|
||
|
|
}
|
||
|
|
|
||
|
|
[HttpGet("all")]
|
||
|
|
[Authorize]
|
||
|
|
public async Task<ActionResult<List<Pill>>> GetAll()
|
||
|
|
{
|
||
|
|
return await service.GetAll();
|
||
|
|
}
|
||
|
|
|
||
|
|
[HttpGet("types")]
|
||
|
|
[Authorize]
|
||
|
|
public ActionResult<List<EnumInfoDto>> GetTypes()
|
||
|
|
{
|
||
|
|
var result = EnumHelper.GetEnumList<PillType>();
|
||
|
|
return result;
|
||
|
|
}
|
||
|
|
|
||
|
|
[HttpGet("rarities")]
|
||
|
|
[Authorize]
|
||
|
|
public ActionResult<List<EnumInfoDto>> GetRarities()
|
||
|
|
{
|
||
|
|
var result = EnumHelper.GetEnumList<PillRarity>();
|
||
|
|
return result;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|