Files
mixtape/zero.Backoffice/Endpoints/Previews/PreviewController.cs
T

36 lines
859 B
C#
Raw Normal View History

2020-09-04 11:50:22 +02:00
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using zero.Core.Api;
using zero.Core.Entities;
using zero.Web.Models;
2020-09-04 11:50:22 +02:00
namespace zero.Web.Controllers
{
public class PreviewController : BackofficeController
{
IPreviewApi Api;
public PreviewController(IPreviewApi api)
{
Api = api;
}
2021-05-04 17:23:52 +02:00
public async Task<EditModel<Preview>> GetById([FromQuery] string id) => Edit(await Api.GetById(id));
2020-09-04 11:50:22 +02:00
2021-11-26 15:47:11 +01:00
public async Task<Result<string>> Add([FromBody] ZeroEntity model)
2020-09-04 11:50:22 +02:00
{
2021-11-26 15:47:11 +01:00
Result<Preview> preview = await Api.Add(model);
return Result<string>.From(preview, preview.Model?.Id);
2020-09-04 11:50:22 +02:00
}
2021-11-26 15:47:11 +01:00
public async Task<Result<string>> Update([FromQuery] string id, [FromBody] ZeroEntity model)
2020-09-04 11:50:22 +02:00
{
2021-11-26 15:47:11 +01:00
Result<Preview> preview = await Api.Update(id, model);
return Result<string>.From(preview, id);
2020-09-04 11:50:22 +02:00
}
}
}