displays hidden posts to owner

This commit is contained in:
2016-12-16 16:38:51 +01:00
parent 9db9649e99
commit f5f3f1462c

View File

@ -39,13 +39,17 @@ namespace Yavsc.Controllers
// GET: Blog
[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))
return UserPosts(id);
return View(_context.Blogspot.Include(
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?}")]
@ -116,7 +120,7 @@ namespace Yavsc.Controllers
_context.SaveChanges();
return RedirectToAction("Index");
}
_logger.LogWarning("Invalid Blog posted ...");
ModelState.AddModelError("Unknown","Invalid Blog posted ...");
return View(blog);
}
[Authorize()]