From b8f79d4e804721b2cb6279b1b564e113c85dd063 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Wed, 28 Nov 2018 13:53:26 +0000 Subject: [PATCH] refactoring --- .../{Deliver => Communicating}/BlogspotController.cs | 9 +++++---- .../{Deliver => Communicating}/CommentsController.cs | 0 .../NotificationsController.cs | 0 3 files changed, 5 insertions(+), 4 deletions(-) rename Yavsc/Controllers/{Deliver => Communicating}/BlogspotController.cs (96%) rename Yavsc/Controllers/{Deliver => Communicating}/CommentsController.cs (100%) rename Yavsc/Controllers/{Deliver => Communicating}/NotificationsController.cs (100%) diff --git a/Yavsc/Controllers/Deliver/BlogspotController.cs b/Yavsc/Controllers/Communicating/BlogspotController.cs similarity index 96% rename from Yavsc/Controllers/Deliver/BlogspotController.cs rename to Yavsc/Controllers/Communicating/BlogspotController.cs index 80f4d5d6..f467d98a 100644 --- a/Yavsc/Controllers/Deliver/BlogspotController.cs +++ b/Yavsc/Controllers/Communicating/BlogspotController.cs @@ -13,6 +13,7 @@ using Yavsc.ViewModels.Auth; using Microsoft.AspNet.Mvc.Rendering; using Yavsc.Models.Blog; using Yavsc.Helpers; + // For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 namespace Yavsc.Controllers @@ -78,13 +79,13 @@ namespace Yavsc.Controllers ).ToList()); } - [Route("/Blog/{id?}")] + [Route("/Blog/{userName}/{pageLen?}/{pageNum?}")] [AllowAnonymous] - public async Task UserPosts(string id) + public async Task UserPosts(string userName, int pageLen=10, int pageNum=0) { - string posterId = (await _context.Users.SingleOrDefaultAsync(u=>u.UserName == id))?.Id ?? null ; + string posterId = (await _context.Users.SingleOrDefaultAsync(u=>u.UserName == userName))?.Id ?? null ; var result = _context.UserPosts(posterId, User.Identity.Name); - return View("Index", result.OrderByDescending(p => p.DateCreated).ToList().GroupBy(p=> p.Title )); + return View("Index", result.OrderByDescending(p => p.DateCreated).ToList().Skip(pageLen*pageNum).Take(pageLen).GroupBy(p=> p.Title )); } // GET: Blog/Details/5 [AllowAnonymous] diff --git a/Yavsc/Controllers/Deliver/CommentsController.cs b/Yavsc/Controllers/Communicating/CommentsController.cs similarity index 100% rename from Yavsc/Controllers/Deliver/CommentsController.cs rename to Yavsc/Controllers/Communicating/CommentsController.cs diff --git a/Yavsc/Controllers/Deliver/NotificationsController.cs b/Yavsc/Controllers/Communicating/NotificationsController.cs similarity index 100% rename from Yavsc/Controllers/Deliver/NotificationsController.cs rename to Yavsc/Controllers/Communicating/NotificationsController.cs