#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Application.Core.FileManagement.Drives.Queries;
using Lumina.Contracts.Responses.FileManagement;
using Lumina.Presentation.Api.Core.Controllers.Common;
using Mediator;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.Core.Controllers.FileManagement;
///
/// Controller for managing file system drives.
///
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/[controller]")]
public class DrivesController : ApiController
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly ISender _mediator;
#endregion
#region ====================================================================== CTOR =====================================================================================
///
/// Initializes a new instance of the class.
///
/// Injected service for mediating commands and queries.
public DrivesController(ISender mediator)
{
_mediator = mediator;
}
#endregion
#region ===================================================================== METHODS ===================================================================================
///
/// Controller action for getting the list of all file system drives.
///
/// Cancellation token that can be used to stop the execution.
[HttpGet("get-drives")]
public async Task GetDrives(CancellationToken cancellationToken)
{
ErrorOr> result = await _mediator.Send(new GetDrivesQuery(), cancellationToken).ConfigureAwait(false);
return result.Match(result => Ok(result), errors => Problem(errors));
}
#endregion
}