using Bootstrap.Admin.Models; using Bootstrap.DataAccess; using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; using System.Linq; namespace Bootstrap.Admin.Controllers.Api { /// /// /// [Route("api/[controller]")] [ApiController] public class MessagesController : ControllerBase { /// /// 根据Id返回不同的消息列表 /// /// /// [HttpGet("{id}")] 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() { var mcm = new MessageCountModel { InboxCount = MessageHelper.Inbox(User.Identity.Name).Count(), SendmailCount = MessageHelper.SendMail(User.Identity.Name).Count(), MarkCount = MessageHelper.Mark(User.Identity.Name).Count(), TrashCount = MessageHelper.Trash(User.Identity.Name).Count() }; return mcm; } } }