public BlogPost GetBlogPost(int id) { BlogPost item = repository.Get(id); if (item == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(item); }
public ActionResult Edit(int id) { var post = _blogPostRepository.Get(id); var viewModel = new EditBlogPostViewModel { BlogPost = Mapper.Map(post), EnableTags = _featureService.EnableTaggableContent.IsEnabledForUser(LoggedInUser) }; return(View(viewModel)); }
public ActionResult Delete(string userName) { var user = Logic.Find(u => u.UserName == userName); IEnumerable <BlogPost> blogPosts = BlogRepo.Get(o => o.UserId == user.Id, null, "", 0, 0); IEnumerable <PostComment> comments = CommentRepo.Get(o => o.UserId == user.Id, null, "", 0, 0); foreach (var item in blogPosts) { IEnumerable <PostComment> commentsFor = CommentRepo.Get(o => o.BlogpostId == item.Id, null, "", 0, 0); foreach (var comment in commentsFor) { CommentRepo.Delete(comment.Id); } BlogRepo.Delete(item.Id); } foreach (var item in comments) { CommentRepo.Delete(item.Id); } CommentRepo.Commit(); Logic.Delete(user); return(RedirectToAction("Index")); }
public IActionResult Detail(int id) { // BlogPost post = _ctx.Posts.Include(m => m.User).Where(p => p.BlogPostID == id).FirstOrDefault(); BlogPost post = _repo.Get(id); return(View(post)); }
public ActionResult Index() { //IBlogPostRepository blogPostRepository = new BlogPostRepository("easyBlog"); IEnumerable <BlogPost> blogPosts = _blogPostRepository.Get(); return(View(blogPosts)); }
public Result UpdatePost(Guid id, BlogPost model, string userName) { var user = _userInfoRepository.GetSingleUser(userName); var post = _blogPostRepository.Get(id); post.Id = model.Id; post.Active = "False"; post.Contents = model.Contents; post.Date = DateTime.Now.ToString(); post.Title = model.Title; _blogPostRepository.Update(post); user.Posts.Add(post); // ?? _userInfoRepository.Update(user); return(Result.AsSuccess()); }
public IActionResult GetBlogPost(int id) { var blogPost = _repository.Get(id); if (blogPost is null) { return(NotFound()); } return(Ok()); }
// GET: BlogPosts public ActionResult Index() { var blogPosts = Repo.Get(null, o => o.OrderByDescending(i => i.DateOfPost), "", 2, 0); foreach (var item in blogPosts) { var sanitizer = new HtmlSanitizer(); //item.PostContent = Markdown.ToPlainText(item.PostContent); item.PostContent = sanitizer.Sanitize(item.PostContent); //item.PostContent = CommonMark.CommonMarkConverter.Convert(item.PostContent); } return(View(blogPosts.ToList())); }
public ActionResult Create(int blogpost = 0) { var viewModel = new EditBlogPostViewModel(); if (blogpost > 0) { var blogPost = _blogPostRepository.Get(blogpost); viewModel.BlogPost = new Article { Title = blogPost.Title, ImageUrl = blogPost.ImageUrl, Body = blogPost.Body }; } return(View(viewModel)); }
public HttpResponseMessage FetchPosts(HttpRequestMessage request) { // this call is not used in the site since it's happening from the view-controller HttpResponseMessage response = null; try { IBlogPostRepository blogPostRepository = _componentLocator.ResolveComponent <IBlogPostRepository>(); IEnumerable <BlogPost> blogPosts = blogPostRepository.Get(); response = request.CreateResponse <BlogPost[]>(HttpStatusCode.OK, blogPosts.ToArray()); } catch (Exception ex) { response = request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex); } return(response); }
// GET: Post/Details/5 public async Task <IActionResult> Details(int id) { if (id == null) { return(NotFound()); } var blogPost = _repo.Get(id); if (blogPost == null) { return(NotFound()); } return(View(blogPost)); }
public BlogPost Get(int id) { return(_blogPostRepository.Get(id)); }
public ActionResult Index() { IEnumerable <BlogPost> blogPosts = _BlogPostRepository.Get(); return(View(blogPosts)); }
public BlogPost Get(string blogPostId) { var result = _repository.Get(blogPostId); return(result); }
public ActionResult Edit(int blogId, int id) { return(View(bprepository.Get(blogId, id))); }
public BlogPost Get(int id) { return(repo.Get(id)); }