2020-05-18 11:53:23 +02:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using zero.Core.Api;
|
|
|
|
|
using zero.Core.Entities;
|
|
|
|
|
using zero.Core.Identity;
|
2020-09-03 14:50:41 +02:00
|
|
|
using zero.Web.Models;
|
2020-05-18 11:53:23 +02:00
|
|
|
|
|
|
|
|
namespace zero.Web.Controllers
|
|
|
|
|
{
|
|
|
|
|
[ZeroAuthorize(Permissions.Sections.Media, PermissionsValue.True)]
|
|
|
|
|
public class MediaFolderController : BackofficeController
|
|
|
|
|
{
|
|
|
|
|
IMediaFolderApi Api;
|
|
|
|
|
|
|
|
|
|
public MediaFolderController(IMediaFolderApi api)
|
|
|
|
|
{
|
|
|
|
|
Api = api;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-09-02 15:46:54 +02:00
|
|
|
public async Task<IActionResult> GetById([FromQuery] string id) => Edit(await Api.GetById(id));
|
2020-05-18 11:53:23 +02:00
|
|
|
|
|
|
|
|
|
2020-09-02 15:46:54 +02:00
|
|
|
public IActionResult GetEmpty([FromServices] IMediaFolder blueprint) => Edit(blueprint);
|
|
|
|
|
|
2020-09-02 16:22:02 +02:00
|
|
|
|
|
|
|
|
public async Task<IActionResult> GetHierarchy([FromQuery] string id) => Json(await Api.GetHierarchy(id));
|
|
|
|
|
|
|
|
|
|
|
2020-09-02 15:46:54 +02:00
|
|
|
public async Task<IActionResult> GetAllAsTree([FromQuery] string parent = null, [FromQuery] string active = null) => Json(await Api.GetAllAsTree(parent, active));
|
2020-05-18 11:53:23 +02:00
|
|
|
|
|
|
|
|
|
2020-09-03 14:50:41 +02:00
|
|
|
[HttpPost]
|
|
|
|
|
public async Task<IActionResult> Move([FromBody] ActionCopyModel model) => Json(await Api.Move(model.Id, model.DestinationId));
|
|
|
|
|
|
|
|
|
|
|
2020-09-02 15:46:54 +02:00
|
|
|
public async Task<IActionResult> Save([FromBody] IMediaFolder model) => Json(await Api.Save(model));
|
2020-05-18 11:53:23 +02:00
|
|
|
|
|
|
|
|
|
2020-09-02 15:46:54 +02:00
|
|
|
public async Task<IActionResult> Delete([FromQuery] string id) => Json(await Api.Delete(id));
|
2020-05-18 11:53:23 +02:00
|
|
|
}
|
|
|
|
|
}
|