Files
mixtape/zero.Web/Controllers/BackofficeController.cs
T

41 lines
832 B
C#
Raw Normal View History

2020-03-22 14:47:59 +01:00
using Microsoft.AspNetCore.Mvc;
2020-04-19 18:22:44 +02:00
using System.Threading.Tasks;
using zero.Core;
2020-04-16 00:56:22 +02:00
using zero.Core.Identity;
2020-04-19 18:22:44 +02:00
using zero.Web.Mapper;
2020-03-22 14:47:59 +01:00
2020-03-24 23:09:29 +01:00
namespace zero.Web.Controllers
2020-03-22 14:47:59 +01:00
{
2020-04-15 14:09:52 +02:00
[ZeroAuthorize]
2020-03-22 14:47:59 +01:00
public abstract class BackofficeController : Controller
{
protected IZeroConfiguration Configuration { get; set; }
2020-04-19 18:22:44 +02:00
protected IMapper Mapper { get; set; }
public BackofficeController(IZeroConfiguration config, IMapper mapper)
{
Configuration = config;
Mapper = mapper;
}
public BackofficeController(IZeroConfiguration config)
{
Configuration = config;
}
2020-04-19 18:22:44 +02:00
protected IActionResult Json<T, TTarget>(T model) where TTarget : class, new()
{
if (model == null)
{
return new StatusCodeResult(404);
}
return Json(Mapper.Map<T, TTarget>(model));
}
2020-03-22 14:47:59 +01:00
}
}