using DomainResults.Mvc;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using WeatherForecast.Services;

namespace WeatherForecast.Controllers;

/// <summary>
/// 
/// </summary>
[Authorize]
[AllowAnonymous]
[Route("api/[controller]")]
public class FilesController : Controller {

  private readonly IFilesService _filesService;

  /// <summary>
  /// 
  /// </summary>
  /// <param name="filesService"></param>
  public FilesController(
    IFilesService filesService
  ) {
    _filesService = filesService;
  }

  /// <summary>
  /// 
  /// </summary>
  /// <param name="siteId"></param>
  /// <param name="userId"></param>
  /// <param name="file"></param>
  /// <returns></returns>
  [HttpPost("{siteId}/{userId}")]
  public IActionResult Post([FromRoute] Guid siteId, [FromRoute] Guid userId, List<IFormFile> file) {
    var result = _filesService.Post(siteId, userId, file);
    return result.ToActionResult();
  }

  /// <summary>
  /// 
  /// </summary>
  /// <param name="siteId"></param>
  /// <param name="userId"></param>
  /// <returns></returns>

  [HttpDelete("{siteId}/{userId}")]
  public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] Guid userId) {
    var result = _filesService.Delete(siteId, userId);
    return result.ToActionResult();
  }
}

