Example #1
0
        public IActionResult Index()
        {
            ViewBag.Name = HttpContext.Session.GetString("Username");
            HomePageViewModel model = new HomePageViewModel()
            {
                Categories = _categoryLogic.GetAll().Select(c => new CategoryViewModel {
                    Id = c.CategoryId, Name = c.Name
                }).ToList(),
                Posts = _postLogic.GetAllPosts().Select(c => new PostViewModel {
                    Title = c.Title, Content = c.Content, PostId = c.PostId, AuraAmount = c.Aura.Amount, PostDate = c.PostDate, UserName = c.User.Name, CategoryName = c.Category.Name
                }).ToList(),
            };

            return(View(model));
        }
Example #2
0
        public IActionResult Index()
        {
            IList <PostViewModel> vmPost = new List <PostViewModel>();

            foreach (var item in postLogic.GetAllPosts())
            {
                vmPost.Add(new PostViewModel
                {
                    Id         = item.Id,
                    Afbeelding = item.Afbeelding,
                    Titel      = item.Titel,
                    Vraag      = item.Vraag,
                    PostId     = item.PostId
                });
            }
            return(View(vmPost));
        }
Example #3
0
        public void GetAllPosts_Expects_True()
        {
            var posts = _postLogic.GetAllPosts();

            Assert.AreEqual(3, posts.Count());
        }