public async Task <IActionResult> BlogList() { List <BlogDetails> ilIst = new List <BlogDetails>(); var listData = await(from Bl in _context.Blog select new { Bl.Id, Bl.Title, Bl.CreatedOn, Bl.Content, Bl.Category } ).ToListAsync(); listData.ForEach(x => { BlogDetails Obj = new BlogDetails(); Obj.Id = x.Id; Obj.Title = x.Title; Obj.CreatedOn = x.CreatedOn; Obj.Content = x.Content; Obj.Category = x.Category.Name; ilIst.Add(Obj); }); return(Json(ilIst)); }
public ActionResult Preview(string content) { WriteBlog wb = CreateWriteBlog(); if (content == null || content == "") { wb.Content = " "; } else { wb.Content = content; } bCRepo.SaveDraft(wb, (int)Session["CurrentBlogId"]); BlogDetails bD = new BlogDetails(); Blog b = bRepo.GetById((int)Session["CurrentBlogId"]); bD.id = b.id; bD.Title = b.Title; bD.CoverPicturePath = b.CoverPicturePath; bD.Content = content; bD.ContentProcess(); return(View(bD)); }
public BlogDetails Update(BlogDetails updateBlog) { // track/manage changes var entity = _db.BlogDetails.Attach(updateBlog); entity.State = EntityState.Modified; return(updateBlog); }
public async Task <IActionResult> Details(int id, CancellationToken cancellationToken) { BlogDetails details = await Mediator.Send(new GetBlogDetailsQuery() { BlogId = id }, cancellationToken); return(View(details)); }
public IActionResult OnGet(int blogDetailsId) { BlogDetails = _blogData.GetById(blogDetailsId); if (BlogDetails == null) { return(RedirectToPage("./NotFound")); } return(Page()); }
public IActionResult BlogDetails(int id) { var blog = bloglar.GetById(id); BlogDetails model = new BlogDetails() { baslik = blog.baslik, blog = blog.blog, img = blog.img }; return(View(model)); }
//retrieving id from BlogDetails public IActionResult OnGet(int?blogDetailsId) { BlogDetails = blogDetailsId.HasValue ? _blogData.GetById(blogDetailsId.Value) : new BlogDetails(); //if no id is found if (BlogDetails == null) { return(RedirectToPage("./NotFound")); } return(Page()); }
public BlogDetails Update(BlogDetails updateBlog) { var blogDetails = _blogDetails.SingleOrDefault(b => b.Id == updateBlog.Id); if (blogDetails != null) { blogDetails.Title = updateBlog.Title; blogDetails.Date = updateBlog.Date; blogDetails.TextBody = updateBlog.TextBody; } return(blogDetails); }
public ActionResult Details(int id) { BlogDetails bd = new BlogDetails(); Blog b = bRepo.GetById(id); bd.Content = bcRepo.GetContent(id); bd.id = b.id; bd.Title = b.Title; bd.Posted = (DateTime)b.Posted; bd.WriterName = bRepo.WriterName(id); bd.Watch = b.Watch; bd.CoverPicturePath = b.CoverPicturePath; bd.ContentProcess(); bRepo.UpdateWatch(id); return(View(bd)); }
public async Task <IActionResult> Edit(BlogDetails unBlog, List <IFormFile> Picture) { foreach (var item in Picture) { if (item.Length > 0) { using (var unStream = new MemoryStream()) { await item.CopyToAsync(unStream); unBlog.Picture = unStream.ToArray(); } } } _context.BlogDetails.Update(unBlog); _context.SaveChanges(); //return View(); return(Redirect("~/BlogsDetails/Index")); }
public BlogDetails Add(BlogDetails newBlogPost) { _db.Add(newBlogPost); return(newBlogPost); }
public BlogDetails Add(BlogDetails newBlogPost) { _blogDetails.Add(newBlogPost); newBlogPost.Id = _blogDetails.Max(b => b.Id) + 1; return(newBlogPost); }
// GET: mb_blog/Details/5 public async Task <IActionResult> Details(int?id, string createid) { if (id == null) { return(NotFound()); } BlogDetails blogDetails = new BlogDetails(); //获取博客信息 var mb_blog = await _context.mb_blog .SingleOrDefaultAsync(m => m.Blog_id == id); //获取用户信息 var mb_user = await _context.mb_user. SingleOrDefaultAsync(m => m.User_id == createid); //将博客信息,和用户信息都传入blogDetails blogDetails.blog = mb_blog; blogDetails.user = mb_user; //搜索用户id=creatid的博客 var blog = from b in _context.mb_blog select b; blog = blog.Where(b => b.Create_id == createid); blogDetails.listblog = await blog.AsNoTracking().ToListAsync(); if (mb_blog == null) { return(NotFound()); } //每次有用户访问了Details,都意味着这篇博客的访问数量+1 mb_blog.PageViews++; try { _context.Update(mb_blog); await _context.SaveChangesAsync(); } catch { } //当当前用户和博客创建者已经是订阅关系了 var mb_relation = _context.mb_relationship.SingleOrDefaultAsync(m => m.UserA_id == User.Identity.Name && m.UserB_id == mb_blog.Create_id); if (mb_relation.Result != null) { ViewData["IsRelation"] = "true"; } //获取所有该博客的评论 var comment = from b in _context.mb_comment select b; comment = comment.Where(m => m.blog_id == id && m.comment_id == 0); List <mb_comment> mb_comment = await comment.AsNoTracking().ToListAsync(); List <CommentDetails> allcomment = new List <CommentDetails>(); foreach (var item in mb_comment) { mb_user user = await _context.mb_user.SingleOrDefaultAsync(m => m.User_id == item.User_publish); allcomment.Add(new CommentDetails(item, user)); } foreach (var item in allcomment) { await dfs(item); } ViewBag.CO = allcomment; return(View(blogDetails)); }