using Api.Services.Interfaces;
using Common.Dtos.Season;
using Common.Dtos.Specialization;
using Microsoft.AspNetCore.Mvc;

namespace Api.Controllers;

[ApiController]
public class SpecializationController(ISpecializationService service) : ControllerBase
{
    private readonly ISpecializationService _service = service;

    [HttpPost]
    [Route("admin/specialization/create")]
    public async Task<ActionResult> CreateAsync([FromBody] CreateSpecializationRequest request)
    {
        var result = await _service.CreateAsync(request);
        return result.Ok ? Ok(result.CreateSpecializationResult) : Conflict(result.Error);
    }

    [HttpGet]
    [Route("admin/specialization")]
    public async Task<ActionResult> GetAllAsync()
    {
        var result = await _service.GetAllAsync();
        return result.Length != 0 ? Ok(result) : NoContent();
    }

    [HttpGet]
    [Route("admin/specialization/paged")]
    public async Task<ActionResult> GetAllPagedAsync([FromQuery] GetSpecializationsRequest request)
    {
        var result = await _service.GetAllPagedAsync(request);
        return Ok(result);
    }
}
