using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; using System.Threading.Tasks; using zero.Core.Api; using zero.Core.Entities; using zero.Core.Identity; using zero.Core.Options; using zero.Web.Models; namespace zero.Web.Controllers { [ZeroAuthorize(Permissions.Sections.Media, PermissionsValue.True)] public class MediaFolderController : BackofficeController { IMediaFolderApi Api; public MediaFolderController(IMediaFolderApi api) { Api = api; } /// /// Get media folder by id /// public async Task GetById([FromQuery] string id) { return await As(await Api.GetById(id)); } /// /// Get empty media folder model /// public IActionResult GetEmpty() { return Json(new MediaFolderEditModel()); } /// /// Get all folders with a specific parent as tree /// public async Task GetAllAsTree([FromQuery] string parent = null, [FromQuery] string active = null) { return Json(await Api.GetAllAsTree(parent, active)); } /// /// Save a media item /// public async Task Save([FromBody] MediaFolderEditModel model) { MediaFolder entity = await Mapper.Map(model, await Api.GetById(model.Id)); return await As(await Api.Save(entity)); } /// /// Deletes a media item /// public async Task Delete([FromQuery] string id) { return await As(await Api.Delete(id)); } } }