* Fixes user's blog index

* Orders posts by descending date
This commit is contained in:
Paul Schneider 2017-04-25 13:36:27 +02:00
commit ee268571b0

View file

@ -71,7 +71,9 @@ namespace Yavsc.Controllers
ViewData["Title"] = id; ViewData["Title"] = id;
return View("Title", _context.Blogspot.Include( return View("Title", _context.Blogspot.Include(
b => b.Author b => b.Author
).Where(x => x.Title == id && (x.Visible || x.AuthorId == uid )).ToList()); ).Where(x => x.Title == id && (x.Visible || x.AuthorId == uid )).OrderByDescending(
x => x.DateCreated
).ToList());
} }
[Route("/Blog/{id?}")] [Route("/Blog/{id?}")]
@ -90,7 +92,8 @@ namespace Yavsc.Controllers
_context.Blogspot.Include( _context.Blogspot.Include(
b => b.Author b => b.Author
).Where(x => x.Author.UserName == id && x.Visible); ).Where(x => x.Author.UserName == id && x.Visible);
return View("Index", result.OrderByDescending(p => p.DateCreated).ToList().GroupBy(p=>p.Title)); // BlogIndexKey
return View("Index", result.OrderByDescending(p => p.DateCreated).ToList().GroupBy(p=>new BlogIndexKey { Title = p.Title, AuthorId = p.AuthorId } ));
} }
// GET: Blog/Details/5 // GET: Blog/Details/5
[AllowAnonymous] [AllowAnonymous]