You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.5 KiB
56 lines
1.5 KiB
13 years ago
|
using System.Web.Mvc;
|
||
|
|
||
13 years ago
|
namespace NzbDrone.Web.Models
|
||
|
{
|
||
13 years ago
|
public class JsonNotificationResult
|
||
13 years ago
|
{
|
||
13 years ago
|
private JsonNotificationResult()
|
||
13 years ago
|
{
|
||
|
Text = string.Empty;
|
||
|
}
|
||
|
|
||
|
public string Title { get; set; }
|
||
|
public string Text { get; set; }
|
||
|
public NotificationType NotificationType { get; set; }
|
||
|
|
||
|
|
||
13 years ago
|
public static JsonResult Info(string title, string text)
|
||
|
{
|
||
13 years ago
|
return GetJsonResult(NotificationType.Info, title, text);
|
||
|
}
|
||
|
|
||
|
public static JsonResult Info(string title)
|
||
|
{
|
||
|
return GetJsonResult(NotificationType.Info, title, string.Empty);
|
||
13 years ago
|
}
|
||
|
|
||
|
public static JsonResult Error(string title, string text)
|
||
|
{
|
||
|
return GetJsonResult(NotificationType.Error, title, text);
|
||
|
}
|
||
|
|
||
13 years ago
|
public static JsonResult Opps(string text)
|
||
|
{
|
||
|
return GetJsonResult(NotificationType.Error, "Opps!", text);
|
||
|
}
|
||
|
|
||
|
|
||
13 years ago
|
public static JsonResult GetJsonResult(NotificationType notificationType, string title, string text)
|
||
|
{
|
||
|
return new JsonResult
|
||
|
{
|
||
13 years ago
|
Data = new JsonNotificationResult { NotificationType = notificationType, Title = title, Text = text },
|
||
13 years ago
|
ContentType = null,
|
||
|
ContentEncoding = null,
|
||
|
JsonRequestBehavior = JsonRequestBehavior.AllowGet
|
||
|
};
|
||
|
}
|
||
13 years ago
|
}
|
||
|
|
||
|
public enum NotificationType
|
||
|
{
|
||
|
Info,
|
||
|
Error
|
||
|
}
|
||
|
|
||
|
}
|