Moved BackOfficeNotificationsController to netcore
This commit is contained in:
@@ -17,7 +17,7 @@ namespace Umbraco.Web.Editors
|
||||
/// resulting message is INotificationModel in which case it will append any Event Messages
|
||||
/// currently in the request.
|
||||
/// </summary>
|
||||
[AppendCurrentEventMessages]
|
||||
//[AppendCurrentEventMessages] // Moved to netcore
|
||||
[PrefixlessBodyModelValidator]
|
||||
public abstract class BackOfficeNotificationsController : UmbracoAuthorizedJsonController
|
||||
{
|
||||
|
||||
@@ -390,7 +390,6 @@
|
||||
<Compile Include="WebApi\AngularJsonOnlyConfigurationAttribute.cs" />
|
||||
<Compile Include="Editors\Binders\MemberBinder.cs" />
|
||||
<Compile Include="WebApi\Filters\AngularAntiForgeryHelper.cs" />
|
||||
<Compile Include="WebApi\Filters\AppendCurrentEventMessagesAttribute.cs" />
|
||||
<Compile Include="WebApi\Filters\ClearAngularAntiForgeryTokenAttribute.cs" />
|
||||
<Compile Include="WebApi\Filters\DisableBrowserCacheAttribute.cs" />
|
||||
<Compile Include="WebApi\Filters\EnableOverrideAuthorizationAttribute.cs" />
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http.Filters;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
|
||||
namespace Umbraco.Web.WebApi.Filters
|
||||
{
|
||||
/// <summary>
|
||||
/// Automatically checks if any request is a non-GET and if the
|
||||
/// resulting message is INotificationModel in which case it will append any Event Messages
|
||||
/// currently in the request.
|
||||
/// </summary>
|
||||
internal sealed class AppendCurrentEventMessagesAttribute : ActionFilterAttribute
|
||||
{
|
||||
public override void OnActionExecuted(HttpActionExecutedContext context)
|
||||
{
|
||||
if (context.Response == null) return;
|
||||
if (context.Request.Method == HttpMethod.Get) return;
|
||||
if (Current.UmbracoContext == null) return;
|
||||
|
||||
var obj = context.Response.Content as ObjectContent;
|
||||
if (obj == null) return;
|
||||
|
||||
var notifications = obj.Value as INotificationModel;
|
||||
if (notifications == null) return;
|
||||
|
||||
var msgs = Current.EventMessages;
|
||||
if (msgs == null) return;
|
||||
|
||||
foreach (var eventMessage in msgs.GetAll())
|
||||
{
|
||||
NotificationStyle msgType;
|
||||
switch (eventMessage.MessageType)
|
||||
{
|
||||
case EventMessageType.Default:
|
||||
msgType = NotificationStyle.Save;
|
||||
break;
|
||||
case EventMessageType.Info:
|
||||
msgType = NotificationStyle.Info;
|
||||
break;
|
||||
case EventMessageType.Error:
|
||||
msgType = NotificationStyle.Error;
|
||||
break;
|
||||
case EventMessageType.Success:
|
||||
msgType = NotificationStyle.Success;
|
||||
break;
|
||||
case EventMessageType.Warning:
|
||||
msgType = NotificationStyle.Warning;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
notifications.Notifications.Add(new BackOfficeNotification
|
||||
{
|
||||
Message = eventMessage.Message,
|
||||
Header = eventMessage.Category,
|
||||
NotificationType = msgType
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user