2016-11-19 14:20:25 +08:00
|
|
|
|
using Bootstrap.Admin.Models;
|
|
|
|
|
using Bootstrap.DataAccess;
|
2016-11-18 16:00:25 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Web.Http;
|
|
|
|
|
|
2016-11-19 14:20:25 +08:00
|
|
|
|
|
2016-11-18 16:00:25 +08:00
|
|
|
|
namespace Bootstrap.Admin.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class MessagesController : ApiController
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2016-11-19 14:20:25 +08:00
|
|
|
|
/// 根据Id返回不同的消息列表
|
2016-11-18 16:00:25 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public IEnumerable<Message> Get(string id)
|
|
|
|
|
{
|
|
|
|
|
var ret = new List<Message>();
|
2016-11-19 14:20:25 +08:00
|
|
|
|
switch (id)
|
|
|
|
|
{
|
2016-11-19 10:32:20 +08:00
|
|
|
|
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;
|
2016-11-19 14:20:25 +08:00
|
|
|
|
}
|
2016-11-18 16:00:25 +08:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
2016-11-19 14:20:25 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 返回各个消息列表的文件个数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[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;
|
|
|
|
|
}
|
2016-11-18 16:00:25 +08:00
|
|
|
|
}
|
2016-11-14 09:42:59 +08:00
|
|
|
|
}
|