public IActionResult Theme(int id, string searchText) { var posts = new List <Post>(); var forum = _forumService.TakeById(id); posts = _postService.TakeSpecificPosts(forum, searchText).ToList(); var listedPosts = posts.Select(x => new ListPostsModel { Id = x.Id, Title = x.Title, AuthorId = x.User.Id, RepliesNumber = x.PostReplies.Count(), AuthorRating = x.User.Rating, Author = x.User.UserName, PostedOn = x.CreatedOn.ToString(), Forum = CreateForumList(x) }); var model = new ForumThemeModel { Posts = listedPosts, Forum = CreateForumList(forum) }; return(View(model)); }
public IActionResult Create(int id) //forumId { var forum = _forumService.TakeById(id); var viewModel = new CreatePostModel { ForumId = forum.Id, ForumName = forum.Title, Author = User.Identity.Name, //claims principle, if were visiting the Create page we are gonna be the author ForumPicture = forum.Image }; return(View(viewModel)); }