2020-05-18 11:53:23 +02:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2020-10-27 15:47:23 +01:00
|
|
|
using System.Collections.Generic;
|
2020-05-18 11:53:23 +02:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-05-04 17:23:52 +02:00
|
|
|
public async Task<EditModel<MediaFolder>> GetById([FromQuery] string id) => Edit(await Api.GetById(id));
|
2020-05-18 11:53:23 +02:00
|
|
|
|
|
|
|
|
|
2021-05-04 17:23:52 +02:00
|
|
|
public EditModel<MediaFolder> GetEmpty([FromServices] MediaFolder blueprint) => Edit(blueprint);
|
2020-09-02 15:46:54 +02:00
|
|
|
|
2020-09-02 16:22:02 +02:00
|
|
|
|
2021-05-04 17:23:52 +02:00
|
|
|
public async Task<IList<MediaFolder>> GetHierarchy([FromQuery] string id) => await Api.GetHierarchy(id);
|
2020-09-02 16:22:02 +02:00
|
|
|
|
|
|
|
|
|
2020-10-27 15:47:23 +01:00
|
|
|
public async Task<IList<TreeItem>> GetAllAsTree([FromQuery] string parent = null, [FromQuery] string active = null) => await Api.GetAllAsTree(parent, active);
|
2020-05-18 11:53:23 +02:00
|
|
|
|
|
|
|
|
|
2020-09-03 14:50:41 +02:00
|
|
|
[HttpPost]
|
2021-05-04 17:23:52 +02:00
|
|
|
public async Task<EntityResult<MediaFolder>> Move([FromBody] ActionCopyModel model) => await Api.Move(model.Id, model.DestinationId);
|
2020-09-03 14:50:41 +02:00
|
|
|
|
|
|
|
|
|
2021-05-04 17:23:52 +02:00
|
|
|
public async Task<EntityResult<MediaFolder>> Save([FromBody] MediaFolder model) => await Api.Save(model);
|
2020-05-18 11:53:23 +02:00
|
|
|
|
|
|
|
|
|
2021-05-04 17:23:52 +02:00
|
|
|
public async Task<EntityResult<MediaFolder>> Delete([FromQuery] string id) => await Api.Delete(id);
|
2020-05-18 11:53:23 +02:00
|
|
|
}
|
|
|
|
|
}
|