Пример #1
0
 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)));
 }
Пример #2
0
 private ForumListingModel BuildForumListing(MyForum forum)
 {
     return(new ForumListingModel
     {
         Id = forum.Id,
         Name = forum.Title,
         Description = forum.Description,
         ImageUrl = forum.ImageUrl
     });
 }
Пример #3
0
        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"));
        }
Пример #4
0
 public async Task Create(MyForum myForum)
 {
     _context.MyForums.Add(myForum);
     await _context.SaveChangesAsync();
 }