added JsonErrorFilter to automatically handle failing ajax calls.

This commit is contained in:
kay.one 2012-01-18 19:58:32 -08:00
parent 7c6d745c86
commit b8ac694fc4
5 changed files with 73 additions and 38 deletions

View file

@ -1,3 +1,5 @@
using System.Web.Mvc;
namespace NzbDrone.Web.Models
{
public class NotificationResult
@ -7,13 +9,31 @@ namespace NzbDrone.Web.Models
Text = string.Empty;
}
public bool IsMessage { get { return true; } }
public string Title { get; set; }
public string Text { get; set; }
public NotificationType NotificationType { get; set; }
public static JsonResult Info(string title, string text)
{
return GetJsonResult(NotificationType.Error, title, text);
}
public static JsonResult Error(string title, string text)
{
return GetJsonResult(NotificationType.Error, title, text);
}
public static JsonResult GetJsonResult(NotificationType notificationType, string title, string text)
{
return new JsonResult
{
Data = new NotificationResult { NotificationType = notificationType, Title = title, Text = text },
ContentType = null,
ContentEncoding = null,
JsonRequestBehavior = JsonRequestBehavior.AllowGet
};
}
}
public enum NotificationType