60 lines
2.1 KiB
C#
60 lines
2.1 KiB
C#
using Abp.AspNetCore.Mvc.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using SplashPage.Authorization;
|
|
using SplashPage.Controllers;
|
|
using SplashPage.Perzonalization;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SplashPage.Web.Host.Controllers
|
|
{
|
|
/// <summary>
|
|
/// Controller for Captive Portal file operations
|
|
/// </summary>
|
|
[Route("api/[controller]")]
|
|
public class CaptivePortalController : SplashPageControllerBase
|
|
{
|
|
private readonly ICaptivePortalAppService _captivePortalAppService;
|
|
|
|
public CaptivePortalController(ICaptivePortalAppService captivePortalAppService)
|
|
{
|
|
_captivePortalAppService = captivePortalAppService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Uploads an image for a captive portal
|
|
/// </summary>
|
|
/// <param name="id">Portal ID</param>
|
|
/// <param name="file">Image file to upload</param>
|
|
/// <param name="imageType">Type of image (logo or background)</param>
|
|
/// <returns>Upload result with image URL</returns>
|
|
[HttpPost("{id}/upload")]
|
|
[AbpMvcAuthorize(PermissionNames.Pages_Captive_Portal)]
|
|
public async Task<IActionResult> UploadImage(int id, IFormFile file, [FromForm] string imageType)
|
|
{
|
|
var result = await _captivePortalAppService.UploadImageAsync(id, file, imageType);
|
|
|
|
if (result.Success)
|
|
{
|
|
return Ok(result);
|
|
}
|
|
|
|
return BadRequest(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Deletes an image from a captive portal
|
|
/// </summary>
|
|
/// <param name="id">Portal ID</param>
|
|
/// <param name="imagePath">Path to the image to delete</param>
|
|
/// <returns>Success indicator</returns>
|
|
[HttpDelete("{id}/image")]
|
|
[AbpMvcAuthorize(PermissionNames.Pages_Captive_Portal)]
|
|
public async Task<IActionResult> DeleteImage(int id, [FromQuery] string imagePath)
|
|
{
|
|
var result = await _captivePortalAppService.DeleteImageAsync(id, imagePath);
|
|
return Ok(new { success = result });
|
|
}
|
|
}
|
|
}
|