displays hidden posts to owner

main
Paul Schneider 9 years ago
parent 9db9649e99
commit f5f3f1462c
1 changed files with 7 additions and 3 deletions

@ -39,13 +39,17 @@ namespace Yavsc.Controllers
// GET: Blog // GET: Blog
[AllowAnonymous] [AllowAnonymous]
public IActionResult Index(string id) public IActionResult Index(string id, int skip=0, int maxLen=25)
{ {
string uid = null;
if (User.IsSignedIn())
uid = User.GetUserId();
if (!string.IsNullOrEmpty(id)) if (!string.IsNullOrEmpty(id))
return UserPosts(id); return UserPosts(id);
return View(_context.Blogspot.Include( return View(_context.Blogspot.Include(
b => b.Author b => b.Author
).Where(p => p.Visible).Take(10)); ).Where(p => p.Visible || p.AuthorId == uid ).OrderByDescending(p => p.Posted)
.Skip(skip).Take(maxLen));
} }
[Route("/Title/{id?}")] [Route("/Title/{id?}")]
@ -116,7 +120,7 @@ namespace Yavsc.Controllers
_context.SaveChanges(); _context.SaveChanges();
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
_logger.LogWarning("Invalid Blog posted ..."); ModelState.AddModelError("Unknown","Invalid Blog posted ...");
return View(blog); return View(blog);
} }
[Authorize()] [Authorize()]

Loading…