/// <summary> /// 获取公告详情页数据 /// </summary> /// <param name="id">公告编号</param> /// <param name="context">数据库上下文对象</param> /// <returns></returns> public async Task <BulletinDetailViewModel> GetBulletinDetailAsync(long id, ApplicationDbContext context) { //Get Bulletin Data var bulletin = await HomeRepository.GetEntityAsync(id, context); //Get Operate Data var record = await PSURepository.GetRecordListAsync(id, context); var list = new List <Operate>(); if (record != null && record.Any()) { list.AddRange(record.Select(item => new Operate { Name = item.UserName, DateTime = item.DateTime.ToString("yyyy-MM-dd HH:mm"), Operating = item.Operate })); } //Bulid Web Model var webModel = new BulletinDetailViewModel { Title = bulletin.Title, Content = bulletin.Content, CreatedOn = bulletin.CreatedOn, OperateName = bulletin.CreatedName, OperateList = list.OrderBy(i => i.DateTime).ToList() }; return(webModel); }
/// <summary> /// 获取公告详情 /// </summary> /// <param name="id">公告编号</param> /// <param name="context">数据库连接上下文对象</param> /// <returns></returns> public async Task <BulletinDetailViewModel> GetBulletinDetailAsync(long id, ApplicationDbContext context) { //Get Bulletin Data var bulletin = await Repository.Areas.Student.HomeRepository.GetEntityAsync(id, context); //Bulid Web Model var webModel = new BulletinDetailViewModel { Title = bulletin.Title, Content = bulletin.Content, CreatedOn = bulletin.CreatedOn, OperateName = bulletin.CreatedName }; return(webModel); }