using Bootstrap.DataAccess;
using System.Collections.Generic;
using System.Web.Http;
using System.Linq;
namespace Bootstrap.Admin.Controllers
{
public class NotificationsController : ApiController
{
///
///
///
///
[HttpGet]
public Notifications Get()
{
var ret = new Notifications();
NotificationHelper.RetrieveNotifications().AsParallel().ForAll(n =>
{
if (n.Category == "0") ret.Users.Add(n);
else if (n.Category == "1") ret.Apps.Add(n);
else if (n.Category == "2") ret.Dbs.Add(n);
});
return ret;
}
///
///
///
///
///
[HttpGet]
public Notifications Get(string id)
{
var ret = new Notifications();
NotificationHelper.RetrieveNotifications().AsParallel().ForAll(n =>
{
if (id != n.Category) return;
if (n.Category == "0") ret.Users.Add(n);
else if (n.Category == "1") ret.Apps.Add(n);
else if (n.Category == "2") ret.Dbs.Add(n);
});
return ret;
}
public class Notifications
{
public Notifications()
{
Users = new List();
Apps = new List();
Dbs = new List();
}
public List Users { get; set; }
public List Apps { get; set; }
public List Dbs { get; set; }
}
}
}