Exemplo n.º 1
0
        public ActionResult List(PagerRequest request, CommentSearchOption search)
        {
            int totalCount;
            var data = _commentRepository.Search(request.PageIndex
                , request.PageSize
                , out totalCount
                , search
                );
    
            var resourceQuerable = _commentRepository.Context.Set<ResourceEntity>().AsQueryable();
            var vo =
                     from u in _commentRepository.Context.Set<UserEntity>()
                     from p in data
                     where p.User_Id == u.Id
                     let commentResource =
                            (from r in resourceQuerable
                             where r.SourceId == p.Id && r.SourceType == (int)SourceType.CommentAudio
                             select r).FirstOrDefault()
                     let sourceResource =
                            (from r in resourceQuerable
                             where r.SourceId == p.SourceId && r.SourceType == p.SourceType
                             select r).FirstOrDefault()
                     select new { C = p, U = u, CR = commentResource, SR = sourceResource };
            var comment = from c in vo.ToList()
                          let p = c.C
                          let u = c.U
                          select new CommentViewModel
                     {
                         CommentResource = MappingManager.ResourceViewMapping(c.CR)
                         ,
                         SourceResource = MappingManager.ResourceViewMapping(c.SR)
                         ,
                         Content = p.Content
                         ,
                         CreatedDate = p.CreatedDate
                         ,
                         CreatedUser = p.CreatedUser
                         ,
                         Id = p.Id
                         ,
                         ReplyId = p.ReplyId
                         ,
                         ReplyUser = p.ReplyUser
                         ,
                         SourceId = p.SourceId
                         ,
                         SourceType = p.SourceType
                         ,
                         Status = p.Status
                         ,
                         UpdatedDate = p.UpdatedDate
                         ,
                         UpdatedUser = p.UpdatedUser
                         ,
                         User_Id = p.User_Id
                         ,
                         CommentUser = new CustomerViewModel
                         {
                             Id = u.Id,
                             Name = u.Name,
                             Nickname = u.Nickname

                         }
                     };
            
            var v = new CommentCollectionViewModel(request, totalCount) { Comments = comment.ToList() };

            return View("List", v);
        }
Exemplo n.º 2
0
 public ActionResult Index(PagerRequest request, CommentSearchOption search)
 {
     return List(request, search);
 }