public IActionResult Topic(int id, string searchQuery) { var forum = _forumService.GetById(id); var posts = _forumService.GetFilteredPosts(id, searchQuery).ToList(); var noResults = (!string.IsNullOrEmpty(searchQuery) && !posts.Any()); var postListings = posts.Select(post => new PostListingModel { Id = post.Id, Forum = BuildForumListing(post), Author = post.User.UserName, AuthorId = post.User.Id, AuthorRating = post.User.Rating, Title = post.Title, DatePosted = post.Created.ToString(CultureInfo.InvariantCulture), RepliesCount = post.Replies.Count() }).OrderByDescending(post => post.DatePosted); var model = new TopicResultModel { EmptySearchResults = noResults, Posts = postListings, SearchQuery = searchQuery, Forum = BuildForumListing(forum), groupId = forum.GroupId }; return(View(model)); }
public IActionResult Topic(int id, string searchQuery) { var forum = _forumService.GetById(id); var posts = new List <Post>(); posts = _postService.GetFilteredPosts(forum, searchQuery).ToList(); var postListings = posts.Select(post => new PostListingModel { Id = post.Id, AuthorId = post.User.Id, AuthorRating = appUser.Rating, AuthorName = post.User.UserName, Title = post.Title, DatePosted = post.Created.ToString(), RepliesCount = post.Replies.Count(), Forum = BuildForumListing(post) }); var model = new ForumTopicModel { Posts = postListings, Forum = BuildForumListing(forum) }; return(View(model)); }
public IActionResult Delete(int id) { var forum = _forum.GetById(id); var model = BuildForumListing(forum); return(View(model)); }
public async Task <IActionResult> TopicAsync(int id) { var forum = _forumService.GetById(id); var posts = new List <Post>(); await _forumService.Create(forum); return(RedirectToAction("Index", "Forum")); }
public IActionResult AddToCart(int id) { var forum = _forumService.GetById(id); if (forum != null) { _cart.AddItem(forum, 1); } return(RedirectToAction("Index")); }
public IActionResult Create(int id) { var forumId = _forumService.GetById(id); var model = new NewPostModel { ForumName = forumId.Title, AuthorName = User.Identity.Name, ForumImageUrl = forumId.ImageUrl, ForumId = forumId.Id }; return(View(model)); }
public ActionResult Create(int id) { var forum = _forumRepositories.GetById(id); var model = new NewPostModel { ForumId = forum.Id, ForumName = forum.Title, AuthorName = User.Identity.Name }; return(View(model)); }
public IActionResult Create(int id) { var forum = _forumService.GetById(id); var model = new CreatePostVM() { ForumName = forum.Title, ForumId = forum.Id, ForumImageUrl = forum.ImageUrl, AuthorName = User.Identity.Name }; return(View(model)); }
public IActionResult Create(int forumId) { var forum = _forumService.GetById(forumId); var newPostViewModel = new NewPostViewModel { ForumName = forum.Title, ForumId = forum.Id, ForumImageUrl = forum.ImageUrl, AuthorName = User.Identity.Name }; return(View(newPostViewModel)); }
//Note id is Forum.id public IActionResult Create(int id) { var forum = _forumService.GetById(id); var model = new NewPostModel { ForumName = forum.Title, ForumId = forum.Id, ForumImageUrl = forum.ImageUrl, AuthorName = User.Identity.Name //User is system defined type }; return(View(model)); }
public IActionResult Create(int id) //this is forum id { var forum = _forumService.GetById(id); var model = new NewPostModel { ForumName = forum.Title, ForumId = forum.Id, ForumImageUrl = forum.ImageUrl, AuthorName = User.Identity.Name //take the user name from actual HTTP context in which we were working so when I am logged in and visiting the page this represents me }; return(View(model)); }
public IActionResult Create(int id) //id is Forum.Id { var forum = _forumService.GetById(id); var model = new NewPostViewModel { ForumName = forum.Title, ForumId = forum.Id, ForumImageUrl = forum.ImageUrl, AuthorName = User.Identity.Name //Get logged in user }; return(View(model)); }
public IActionResult Create(int id) { var forum = forumService.GetById(id); var viemModel = new NewPostViewModel() { ForumId = forum.Id, ForumName = forum.Title, ForumImageUrl = forum.ImageURL, AuhtorName = User.Identity.Name }; return(View(viemModel)); }
public IActionResult Create(int id) { // Note id variable is equal to the Forum.Id var forum = _forumService.GetById(id); var model = new NewPostModel { ForumName = forum.Title, ForumId = forum.Id, ForumImageUrl = forum.ImageUrl, AuthorName = User.Identity.Name, }; return(View(model)); }
public IActionResult Create(int id) { // note id here - is Forum.Id var forum = _forumService.GetById(id); var model = new NewPostModel { ForumName = forum.Title, ForumId = forum.Id, AuthorName = User.Identity.Name, ForumImageUrl = forum.ImageUrl }; return(View(model)); }
public IActionResult Create(int id) { //id is Forum.Id var forum = _forumService.GetById(id); var newPost = new NewPostModel { ForumID = forum.Id, ForumName = forum.Name, ForumImageUrl = forum.ImageUrl, AuthorName = User.Identity.Name }; return(View(newPost)); }
public IActionResult Create(int id) { // id adalah forum.Id var forum = _forumService.GetById(id); var model = new NewPostModel { NamaForum = forum.Judul, ForumId = forum.Id, ForumImageUrl = forum.ImageUrl, NamaPembuat = User.Identity.Name }; return(View(model)); }
public IActionResult Create(int id) { // Note id is Forum.Id var forum = _forumService.GetById(id); var model = new NewPostModel { ForumName = forum.Title, ForumId = forum.Id, ForumImageUrl = forum.ImageUrl, AuthorName = User.Identity.Name // claims principal and on this we have this identity property - claims idenity associated }; return(View(model)); }
public IActionResult Create(int id) { //Note ID is Forum ID var forum = _forumService.GetById(id); var model = new NewPostModel { ForumName = forum.Title, ForumId = forum.Id, ForumImageUrl = forum.ImageUrl, //User avaible from Claims Principle AuthorName = User.Identity.Name }; return(View(model)); }
public IActionResult Topic(int id) { var forum = _forumService.GetById(id); var posts = forum.Posts; // ToDo : tu jest blad postListing jest nullem var postListings = posts.Select(post => new PostListingModel { Id = post.Id, AuthorId = post.User.Id, AuthorRating = post.User.Rating, Title = post.Title, DatePosted = post.Created.ToString(), RepliesCount = post.Replies.Count(), Forum = BuildForumListing(post) }); var model = new ForumTopicModel { Posts = postListings, Forum = BuildForumListing(forum) }; return(View(model)); }
public IActionResult Topic(int forumId, string searchQuery) { var forum = _forumService.GetById(forumId); var posts = _postService.GetFilteredPosts(forum, searchQuery).ToList(); //Convert forum into list of posts. var postList = posts.Select(p => new ForumTopicListingModel { Id = p.Id, Title = p.Title, AuthorId = p.User.Id, AuthorName = p.User.UserName, AuthorRating = p.User.Rating, Created = p.Created.ToLocalTime().ToString("d"), RepliesCount = p.Replies.Count(), Forum = BuildForumListing(p) }); var model = new ForumTopicModel { Forum = BuildForumListing(forum), PostList = postList }; return(View(model)); }
public IActionResult Details(int id) { var forum = _forum.GetById(id); var posts = forum.Posts; var postVM = posts.Select(post => new PostViewModel { Id = post.Id, AuthorId = post.User.Id, AuthorRating = post.User.Rating, Title = post.Title, DatePosted = post.Created.ToString(), RepliesCount = post.Replies.Count(), Forum = BuildForumViewModel(post) }); var model = new ForumDetailsModel { Posts = postVM, Forum = BuildForumViewModel(forum) }; return(View(model)); }
public IActionResult Topic(int id, string searchQuery) { var forum = _forumService.GetById(id); ForumVM forumVM = BuildForumModel(forum); var posts = new List <Post>(); if (!string.IsNullOrEmpty(searchQuery)) { posts = _postService.GetFilteredPosts(forum, searchQuery).ToList(); } else { posts = forum.Posts.ToList(); } var postsTopicVM = posts.Select(p => new PostVM() { Id = p.Id, Title = p.Title, //AuthorId = p.Author.Id, //AuthorName = p.Author.UserName, //AuthorRating = p.Author.Rating, CreatedAt = p.CreatedAt, RepliesCount = p.Replies.Count(), Forum = BuildForumModel(p) }); ForumTopicVM topicVM = new ForumTopicVM() { Forum = forumVM, Posts = postsTopicVM }; return(View(topicVM)); }
public IActionResult Topic(int Id, int pageZ = 1) { var forum = _forumService.GetById(Id); var postList = forum.Posts.OrderByDescending(post => post.Created).Where(p => p.Status == true) .Select(post => new PostViewModel { Id = post.Id, Title = post.Title, AuthorId = post.User.Id, AuthorRating = post.User.Rating, AuthorName = post.User.UserName, ImageProfile = post.User.ProfileImageUrl, Created = post.Created, RepliesCount = post.Replies.Count(), Forum = BuildForumListing(post) }); var model = new ForumIndexTopicModel { Posts = postList, Forum = new ForumViewModel { Id = forum.Id, Title = forum.Title, Description = forum.Description, ImageUrl = forum.ImageUrl } }; //var result = await PagingList.CreateAsync(IQueryable<model>, 10, pageZ); return(View(model)); }
public IActionResult Topic(int id, string searchQuery) { var forum = _forumService.GetById(id); //assign the instance of the particular forum var posts = new List <Post>(); posts = _postService.GetFilteredPosts(forum, searchQuery).ToList(); //posts = forum.Posts.ToList(); //assign all the post from the particular forum //var posts = _postService.GetPostsByForum(id); var postListings = posts.Select(post => new PostListingModel //create a new ViewModel instance and map all raw posts into view model named post listing model { Id = post.Id, AuthorId = post.User.Id, AuthorName = post.User.UserName, AuthorRating = post.User.Rating, Title = post.Title, DatePosted = post.Created.ToString(), //store as a string because we can control the way that we display this down on the page RepliesCount = post.Replies.Count(), Forum = BuildForumListing(post) //it's a reference to this forum }); var model = new ForumTopicModel //create a instance of viewmodel - posts are our postlistingmodel and forum is { Posts = postListings, Forum = BuildForumListing(forum) }; return(View(model)); }
public async Task <IActionResult> Create(int id) { var post = _postService.GetById(id); var forum = _forumService.GetById(post.Forum.Id); var user = await _userManager.FindByNameAsync(User.Identity.Name); var model = new PostReplyModel { PostContent = post.Content, PostTitle = post.Title, PostId = post.Id, ForumName = forum.Title, ForumId = forum.Id, ForumImageUrl = forum.ImageUrl, AuthorName = User.Identity.Name, AuthorImageUrl = user.ProfileImageUrl, AuthorId = user.Id, AuthorRating = user.Rating, IsAuthorAdmin = user.IsAdmin, Date = DateTime.Now }; return(View(model)); }
public IActionResult Topic(int id, string searchQuery) { var forum = _forumService.GetById(id); //var posts = new List<Post>(); var posts = _forumService.GetFilteredPosts(id, searchQuery).ToList(); var noResults = (!string.IsNullOrEmpty(searchQuery) && !posts.Any()); //if (!String.IsNullOrEmpty(searchQuery)) //{ posts = _postService.GetFilteredPosts(forum, searchQuery).ToList(); //} //posts = forum.Posts.ToList(); var postListings = posts.Select(post => new PostListingModel { Id = post.Id, AuthorId = post.User.Id, AuthorRating = post.User.Rating, AuthorName = post.User.UserName, Title = post.Subject, DatePosted = post.Created.ToString(), RepliesCount = post.Replies.Count(), Forum = BuildForumListing(post) }).OrderByDescending(post => post.DatePosted); var model = new ForumTopicModel { Posts = postListings, Forum = BuildForumListing(forum), SearchQuery = searchQuery, EmptySearchResults = noResults }; return(View(model)); }
// Get Forum public IActionResult Topic(int id, string searchQuery) { var forum = _forumService.GetById(id); // var posts = _postsService.GetPostsByForum(id); // get the Posts from particular Forum //var posts = forum.Posts; var posts = _forumService.GetFilteredPosts(id, searchQuery).ToList(); var noResults = (!string.IsNullOrEmpty(searchQuery) && !posts.Any()); var postListings = posts.Select(post => new PostListingModel { Id = post.Id, AuthorId = post.User.Id, AuthorRating = post.User.Rating, AuthorName = post.User.UserName, Title = post.Title, DatePosted = post.Created.ToString(), RepliesCount = post.Replies.Count(), Forum = BuildForumListing(post) }); var model = new ForumTopicModel { EmptySearchResults = noResults, SearchQuery = searchQuery, Posts = postListings, Forum = BuildForumListing(forum) }; return(View(model)); }
public IActionResult Detail(int id) { var forum = _forumService.GetById(id); var userId = _userManager.GetUserId(User); var user = _userManager.FindByIdAsync(userId).Result; var model = new ForumDetailModel { Id = forum.Id, Name = forum.Title, Descr = forum.Description, Val = forum.Value, ImgUrl = forum.ImageUrl, ImgCount = forum.ImageCount, FlUrl = forum.FileUrl, VidUrl = forum.VideoUrl, Start = forum.DateCreate, Finish = forum.DateFinish, Com = forum.Comment, FIO = user.FIO, Pat = user.UserName }; return(View(model)); }
public IActionResult Detail(int id) { var forum = _forumService.GetById(id); var posts = forum.Posts; var postListing = posts.Select(post => new PostListingModel { Id = post.Id, AuthorId = post.User.Id, AuthorName = post.User.UserName, AuthorRating = post.User.Rating, Title = post.Title, DateCreated = post.Created.ToString(), RepliesCount = post.Replies.Count(), Forum = BuildForumListing(post) }).ToList(); var model = new ForumDetailModel { Posts = postListing, Forum = BuildForumListing(forum) }; return(View(model)); }