Files
mixtape/zero.Backoffice/Controllers/ZeroBackofficeController.cs
T

39 lines
898 B
C#
Raw Normal View History

2021-11-23 15:43:21 +01:00
using Microsoft.AspNetCore.Mvc;
namespace zero.Backoffice.Controllers;
[ZeroAuthorize]
[DisableBrowserCache]
public abstract class ZeroBackofficeController : ControllerBase
{
/// <summary>
/// Create an edit model with associated metadata and permissions from a model
/// </summary>
2021-11-26 15:47:11 +01:00
protected DisplayModel<T> GetEditModel<T>(T model)
2021-11-23 15:43:21 +01:00
{
2021-11-26 15:47:11 +01:00
return GetEditModel<T, DisplayModel<T>>(new DisplayModel<T>() { Entity = model });
2021-11-23 15:43:21 +01:00
}
/// <summary>
/// Create an edit model with associated metadata and permissions from a model
/// </summary>
2021-11-26 15:47:11 +01:00
protected TWrapper GetEditModel<T, TWrapper>(TWrapper editModel) where TWrapper : DisplayModel<T>, new()
2021-11-23 15:43:21 +01:00
{
editModel.Meta = new()
{
Token = null,
IsShared = false
};
editModel.Permissions = new()
{
CanCreate = true,
CanEdit = true,
CanDelete = true
};
return editModel;
}
}