public IActionResult Index() { UserServices services = new UserServices(this.UserServices.ConnectString); services.BeginCache(); HomeModel model = new HomeModel(); model.Forums = this.ForumServices.Fetch(); model.Topics = EMapper.Mapper <Services.Models.Topic, Models.TopicModel>(this.TopicServices.Fetch(x => x.IsTop), p => p.Author = EMapper.Mapper <Services.Models.Users, Models.UserModel>(services.SingleOrDefaultById(p.UID))); model.Comprehensiveness = EMapper.Mapper <Services.Models.Topic, Models.TopicModel>(this.TopicServices.Comprehensive(20), p => p.Author = EMapper.Mapper <Services.Models.Users, Models.UserModel>(services.SingleOrDefaultById(p.UID))); services.EndCache(); return(View(model)); }
public IActionResult Detail(long id) { var model = AppServices.SingleOrDefaultById(id); var topic = PuppyBBS.Services.EMapper.Mapper<Services.Models.Topic, TopicModel>(model); topic.Author = PuppyBBS.Services.EMapper.Mapper<Services.Models.Users, UserModel>(UserServices.SingleOrDefaultById(topic.UID)); var pg = CommentServices.PageQuery(1, 15, x => x.TID == topic.TID); topic.Comment = new NPoco.Page<CommentsModel>() { CurrentPage = pg.CurrentPage, ItemsPerPage = pg.ItemsPerPage, TotalItems = pg.TotalItems, TotalPages = pg.TotalPages }; topic.Comment.Items = EMapper.Mapper<Comments, CommentsModel>(CommentServices.FillAuthor(pg.Items), x => { if (x.PraiseID == null) { x.PraiseID = new long[0]; } }); return View(topic); }