public IEnumerable <Post> GetFilteredPosts(MyForum forum, string searchQuery) { return(string.IsNullOrEmpty(searchQuery) ? forum.Posts : forum.Posts.Where(post => post.Title.Contains(searchQuery) || post.Content.Contains(searchQuery))); }
private ForumListingModel BuildForumListing(MyForum forum) { return(new ForumListingModel { Id = forum.Id, Name = forum.Title, Description = forum.Description, ImageUrl = forum.ImageUrl }); }
public async Task <ActionResult> AddForum(AddForumModel model) { var imageUri = "/images/default.png"; if (model.ImageUpload != null) { imageUri = "/images/forum/" + model.ImageUpload.FileName; var path = Server.MapPath("~" + imageUri); model.ImageUpload.SaveAs(path); } var forum = new MyForum { Title = model.Title, Description = model.Description, Created = DateTime.Now, ImageUrl = imageUri }; await _myForumService.Create(forum); return(RedirectToAction("Index", "Forum")); }
public async Task Create(MyForum myForum) { _context.MyForums.Add(myForum); await _context.SaveChangesAsync(); }