using Api.Extensions;
using Api.Services.Interfaces;
using Common.Dtos.Student;
using Common.Extensions;
using Microsoft.AspNetCore.Mvc;
using System.Reflection;

namespace Api.Controllers;

[ApiController]
public class VersionController() : ControllerBase
{
    [HttpGet]
    [Route("version")]
    public async Task<ActionResult> GetVersion()
    {
        var version = GetVersionNumber();
        return Ok(version);
    }

    public static string GetVersionNumber()
    {
        var assembly = Assembly.GetExecutingAssembly();
        var version = new VersionResponse { Version = assembly.GetName().Version!.ToString() };
        return version.ToJson();
    }
}

public class VersionResponse
{
    public string Version { get; set; } = string.Empty;
}
