Example #1
0
        public void GetAllPostsByUser_Expects_True()
        {
            List <Post> posts = null;

            posts = _postLogic.GetAllPostsByUser(1);

            Assert.AreEqual(1, posts.Count());
        }
        public IActionResult UserProfile(int user_id)
        {
            User user = _accountLogic.GetUserById(user_id);
            ProfilePageViewModel model = new ProfilePageViewModel()
            {
                User = new UserViewModel()
                {
                    Name = user.Name, UserId = user.UserId
                },
                Posts = _postLogic.GetAllPostsByUser(user.UserId).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(),
                Categories = _categoryLogic.GetAll().Select(c => new CategoryViewModel {
                    Id = c.CategoryId, Name = c.Name
                }).ToList(),
            };

            return(View(model));
        }