using Bootstrap.Admin.Models;
using Bootstrap.DataAccess;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
namespace Bootstrap.Admin.Controllers
{
public class MessagesController : ApiController
{
///
/// 根据Id返回不同的消息列表
///
///
///
[HttpGet]
public IEnumerable Get(string id)
{
var ret = new List();
switch (id)
{
case "inbox": ret = MessageHelper.Inbox(User.Identity.Name).ToList();
break;
case "sendmail": ret = MessageHelper.SendMail(User.Identity.Name).ToList();
break;
case "mark": ret = MessageHelper.Mark(User.Identity.Name).ToList();
break;
case "trash": ret = MessageHelper.Trash(User.Identity.Name).ToList();
break;
}
return ret;
}
///
/// 返回各个消息列表的文件个数
///
///
///
[HttpGet]
public MessageCountModel Get()
{
MessageCountModel mcm = new MessageCountModel();
mcm.inboxCount = MessageHelper.Inbox(User.Identity.Name).Count();
mcm.sendmailCount = MessageHelper.SendMail(User.Identity.Name).Count();
mcm.markCount = MessageHelper.Mark(User.Identity.Name).Count();
mcm.trashCount = MessageHelper.Trash(User.Identity.Name).Count();
return mcm;
}
}
}