From f5f3f1462c0652c9ea9604fb350a03355f2ab803 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Fri, 16 Dec 2016 16:38:51 +0100 Subject: [PATCH 1/8] displays hidden posts to owner --- Yavsc/Controllers/BlogspotController.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Yavsc/Controllers/BlogspotController.cs b/Yavsc/Controllers/BlogspotController.cs index b6d21470..4a60ae66 100644 --- a/Yavsc/Controllers/BlogspotController.cs +++ b/Yavsc/Controllers/BlogspotController.cs @@ -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()] From 281abd002738bfdc5fc8443e96e53b2903ca3fa2 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Fri, 16 Dec 2016 16:39:05 +0100 Subject: [PATCH 2/8] formatting --- Yavsc/Views/Blogspot/Index.cshtml | 33 +++++++++++++++++++++++++++---- Yavsc/Views/Home/Chat.cshtml | 2 +- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Yavsc/Views/Blogspot/Index.cshtml b/Yavsc/Views/Blogspot/Index.cshtml index afc45988..66dcd572 100644 --- a/Yavsc/Views/Blogspot/Index.cshtml +++ b/Yavsc/Views/Blogspot/Index.cshtml @@ -9,6 +9,7 @@

@SR["Create a new article"]

+ @foreach (var item in Model) { - - +
@@ -17,10 +18,12 @@
- @Html.DisplayFor(modelItem => item.Photo) - @item.Title + var trclass = (item.Visible)?"vpost":"ipost"; + +
+ + @item.Title @item.Author.UserName
@@ -47,5 +50,27 @@ }
+ diff --git a/Yavsc/Views/Home/Chat.cshtml b/Yavsc/Views/Home/Chat.cshtml index f1d45341..c1a5cdf3 100644 --- a/Yavsc/Views/Home/Chat.cshtml +++ b/Yavsc/Views/Home/Chat.cshtml @@ -26,7 +26,7 @@

Salons

Utilisateurs

-