示例#1
0
        // GET: Post
        public ActionResult Index()
        {
            List <string> categories = new List <string> {
                "type1", "type2"
            };

            ViewData["filtre"] = new SelectList(categories);
            List <PostViewModel> List = new List <PostViewModel>();


            var a = SP.GetAll();

            foreach (var i in a)
            {
                PostViewModel avm = new PostViewModel();
                avm.IdPost          = i.IdPost;
                avm.Title           = i.Title;
                avm.Description     = i.Description;
                avm.Photo           = i.Photo;
                avm.Like            = i.Like;
                avm.PostedOn        = i.PostedOn;
                avm.Category        = (Models.Categories)i.Category;
                avm.ParticipantName = i.ParticipantName;
                avm.commentss       = i.commentss;
                List.Add(avm);
            }
            return(View(List));
        }
        public List <PostDTO> GetAllPosts()
        {
            var lp = _svcPost.GetAll();

            List <PostDTO> lpDto = new List <PostDTO>();

            lpDto = iMapper.Map <List <Post>, List <PostDTO> >(lp);
            return(lpDto);
        }
示例#3
0
        // Interfata ILoadData
        public List <PostDTO> GetAllPosts()
        {
            var lp = _svcPost.GetAll();
            // Constructie lista PostDTO
            List <PostDTO> lpDto = new List <PostDTO>();

            lpDto = iMapper.Map <List <Post>, List <PostDTO> >(lp);
            return(lpDto);

            #region Comentariu

            /* Cam acest lucru face AutoMapper.
             * Construieste DTO din obiectele din server (EF)
             * foreach (var p in lp)
             * {
             * PostDTO pd = new PostDTO()
             * {
             * PostId = p.PostId,
             * Title = p.Title
             * };
             * if (p.Comments.Count > 0)
             * {
             * foreach (var c in p.Comments)
             * {
             * //pd.Comments = new List<CommentDTO>();
             * CommentDTO cd = new CommentDTO();
             * cd.CommentId = c.CommentId;
             * cd.CommentText = c.CommentText;
             * //cd.PostId = c.PostId;
             * //cd.PostPostId = c.PostPostId;
             * pd.Comments.Add(cd);
             * }
             * }
             * lpDto.Add(pd);
             * }
             * return lpDto;
             */
            #endregion
        }
示例#4
0
        public IQueryable <Post> GetTache()
        {
            List <Post> taches = ts.GetAll().ToList();

            return(taches.AsQueryable());
        }