Files
mixtape/zero.Web/Filters/BackofficeFilterAttribute.cs
T
2020-11-22 22:31:45 +01:00

31 lines
731 B
C#

using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using System;
using zero.Web.Controllers;
namespace zero.Web.Filters
{
public class BackofficeFilterAttribute : IActionFilter
{
const string SCOPE_KEY = "scope";
public void OnActionExecuting(ActionExecutingContext context)
{
Type type = context.Controller.GetType();
if (typeof(BackofficeController).IsAssignableFrom(type))
{
if (context.HttpContext.Request.Query.TryGetValue(SCOPE_KEY, out var scope))
{
(context.Controller as BackofficeController).OnScopeChanged(scope.ToString());
}
}
}
public void OnActionExecuted(ActionExecutedContext context)
{
}
}
}