A listing of allowed posts only
This commit is contained in:
parent
90766547d4
commit
5cdb755828
1 changed files with 22 additions and 6 deletions
|
|
@ -41,14 +41,30 @@ namespace Yavsc.Controllers
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public IActionResult Index(string id, int skip=0, int maxLen=25)
|
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(
|
string uid = User.GetUserId();
|
||||||
b => b.Author
|
long[] usercircles = _context.Circle.Include(c=>c.Members).Where(c=>c.Members.Any(m=>m.MemberId == uid))
|
||||||
).Where(p => p.Visible || p.AuthorId == uid ).OrderByDescending(p => p.DateCreated)
|
.Select(c=>c.Id).ToArray();
|
||||||
|
IQueryable<Blog> posts ;
|
||||||
|
if (usercircles != null) {
|
||||||
|
posts = _context.Blogspot.Include(
|
||||||
|
b => b.Author
|
||||||
|
).Include(p=>p.ACL).Where(p=>p.Visible && (p.ACL.Count == 0 || p.ACL.Any(a=> usercircles.Contains(a.CircleId))));
|
||||||
|
/* posts = _context.Blogspot.Include(
|
||||||
|
b => b.Author
|
||||||
|
).Include(p=>p.ACL).Where(p=>p.Visible || p.ACL.Any(a => usercircles.Contains(a.Allowed)
|
||||||
|
)); */
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
posts = _context.Blogspot.Include(
|
||||||
|
b => b.Author
|
||||||
|
).Include(p=>p.ACL).Where(p=>p.Visible && p.ACL.Count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return View(posts
|
||||||
|
.OrderByDescending(p => p.DateCreated)
|
||||||
.Skip(skip).Take(maxLen));
|
.Skip(skip).Take(maxLen));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue