42 lines
1.5 KiB
C#
42 lines
1.5 KiB
C#
using System;
|
|
using System.Web.Mvc;
|
|
using Kreta.BusinessLogic.Classes;
|
|
using Kreta.Web.Models;
|
|
|
|
namespace Kreta.Web.Security
|
|
{
|
|
/// <summary>
|
|
/// "Karbantartás"-hoz használható attribute, ami
|
|
/// </summary>
|
|
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
|
|
public class MvcFeatureMaintenanceAttribute : ActionFilterAttribute
|
|
{
|
|
private readonly string _featureName;
|
|
|
|
public MvcFeatureMaintenanceAttribute(string featureName)
|
|
{
|
|
_featureName = featureName;
|
|
}
|
|
|
|
public override void OnActionExecuting(ActionExecutingContext filterContext)
|
|
{
|
|
var result = AuthorizeHelper.CheckMaintenanceInProgress(_featureName);
|
|
if (result != null && !string.IsNullOrWhiteSpace(SDAConvert.ToString(result["C_TARTALOM"])))
|
|
{
|
|
var view = new PartialViewResult
|
|
{
|
|
ViewName = "~/Views/HibaOldal/MaintenancePartial.cshtml",
|
|
ViewData = new ViewDataDictionary<MaintenanceModel>(new MaintenanceModel()
|
|
{
|
|
Title = SDAConvert.ToString(result["C_CIM"]),
|
|
Message = SDAConvert.ToString(result["C_TARTALOM"])
|
|
})
|
|
};
|
|
filterContext.Result = view;
|
|
return;
|
|
}
|
|
|
|
base.OnActionExecuting(filterContext);
|
|
}
|
|
}
|
|
}
|