Files
mixtape/zero.Web/Filters/BackofficeFilterAttribute.cs
T

31 lines
731 B
C#
Raw Normal View History

2020-11-18 12:00:51 +01:00
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using System;
using zero.Web.Controllers;
namespace zero.Web.Filters
{
public class BackofficeFilterAttribute : IActionFilter
{
2020-11-22 22:31:45 +01:00
const string SCOPE_KEY = "scope";
2020-11-18 12:00:51 +01:00
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)
{
}
}
}