new output for media

This commit is contained in:
2020-09-02 15:46:54 +02:00
parent bf12f8370e
commit 3fc06b5fd5
19 changed files with 427 additions and 548 deletions
+7 -41
View File
@@ -1,11 +1,8 @@
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
{
@@ -20,49 +17,18 @@ namespace zero.Web.Controllers
}
/// <summary>
/// Get media folder by id
/// </summary>
public async Task<IActionResult> GetById([FromQuery] string id)
{
return await As<MediaFolder, MediaFolderEditModel>(await Api.GetById(id));
}
public async Task<IActionResult> GetById([FromQuery] string id) => Edit(await Api.GetById(id));
/// <summary>
/// Get empty media folder model
/// </summary>
public IActionResult GetEmpty()
{
return Json(new MediaFolderEditModel());
}
public IActionResult GetEmpty([FromServices] IMediaFolder blueprint) => Edit(blueprint);
public async Task<IActionResult> GetAllAsTree([FromQuery] string parent = null, [FromQuery] string active = null) => Json(await Api.GetAllAsTree(parent, active));
/// <summary>
/// Get all folders with a specific parent as tree
/// </summary>
public async Task<IActionResult> GetAllAsTree([FromQuery] string parent = null, [FromQuery] string active = null)
{
return Json(await Api.GetAllAsTree(parent, active));
}
public async Task<IActionResult> Save([FromBody] IMediaFolder model) => Json(await Api.Save(model));
/// <summary>
/// Save a media item
/// </summary>
public async Task<IActionResult> Save([FromBody] MediaFolderEditModel model)
{
MediaFolder entity = await Mapper.Map(model, await Api.GetById(model.Id));
return await As<MediaFolder, MediaFolderEditModel>(await Api.Save(entity));
}
/// <summary>
/// Deletes a media item
/// </summary>
public async Task<IActionResult> Delete([FromQuery] string id)
{
return await As<MediaFolder, MediaFolderEditModel>(await Api.Delete(id));
}
public async Task<IActionResult> Delete([FromQuery] string id) => Json(await Api.Delete(id));
}
}