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)); }
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)); }
public void GetAllPosts_Expects_True() { var posts = _postLogic.GetAllPosts(); Assert.AreEqual(3, posts.Count()); }