From 140b1d6bcc89861d15c42ebe03dd98bea3777cab Mon Sep 17 00:00:00 2001 From: tmont Date: Sun, 27 Feb 2011 01:14:56 +0000 Subject: [PATCH] * added logo * updated footer styles * paged the browse data --- .../Controllers/QuoteController.cs | 25 +++++++++++---- Src/VideoGameQuotes.Web/Global.asax.cs | 2 +- Src/VideoGameQuotes.Web/Models/BrowseModel.cs | 2 +- .../Models/QualifiedBrowseModel.cs | 5 +-- .../Services/QuoteService.cs | 23 ++++---------- .../VideoGameQuotes.Web.csproj | 3 ++ Src/VideoGameQuotes.Web/Views/Home/Index.aspx | 15 +++++---- .../Views/Quote/PagingMenu.ascx | 8 +++-- .../Views/Quote/QualifiedBrowse.aspx | 17 ++++++---- .../Views/Shared/Site.Master | 6 ++-- Src/VideoGameQuotes.Web/media/css/global.css | 30 ++++++++++++++---- .../media/images/vgquotes.png | Bin 0 -> 17969 bytes 12 files changed, 84 insertions(+), 52 deletions(-) create mode 100644 Src/VideoGameQuotes.Web/media/images/vgquotes.png diff --git a/Src/VideoGameQuotes.Web/Controllers/QuoteController.cs b/Src/VideoGameQuotes.Web/Controllers/QuoteController.cs index 0742b56..0ee76fe 100644 --- a/Src/VideoGameQuotes.Web/Controllers/QuoteController.cs +++ b/Src/VideoGameQuotes.Web/Controllers/QuoteController.cs @@ -6,6 +6,7 @@ using Portoa.Persistence; using Portoa.Search; using Portoa.Validation.DataAnnotations; using Portoa.Web.Controllers; +using Portoa.Web.Models; using Portoa.Web.Results; using Portoa.Web.Security; using VideoGameQuotes.Api; @@ -25,15 +26,27 @@ namespace VideoGameQuotes.Web.Controllers { this.quoteSearcher = quoteSearcher; } - public ActionResult Browse(BrowseModel model) { + public ActionResult Browse(BrowseModel model, int page = 1) { + if (page < 1) { + return new StatusOverrideResult(View("BadPaging")) { StatusCode = HttpStatusCode.BadRequest }; + } + if (model.IsEmpty) { return View("DefaultBrowse"); } - return View("QualifiedBrowse", new QualifiedBrowseModel(model) { - Quotes = quoteService.GetBrowsableQuotes(model), - User = currentUserProvider.CurrentUser - }); + model.CurrentUser = currentUserProvider.CurrentUser; + var pagingModel = new PagedModel { + CurrentPage = page, + PageSize = 10 + }; + + int totalCount; + var quotes = quoteService.GetBrowsableQuotes(model, pagingModel.Start, pagingModel.End, out totalCount); + pagingModel.Records = quotes; + pagingModel.TotalCount = totalCount; + + return View("QualifiedBrowse", new QualifiedBrowseModel(model) { PagedModel = pagingModel }); } [HttpPost, VerifyUser] @@ -86,7 +99,7 @@ namespace VideoGameQuotes.Web.Controllers { PageSize = pageSize }; - model.Records = quoteService.GetMostRecentQuotes(model.Start, model.End, out totalCount); + model.Records = quoteService.GetRecentQuotes(model.Start, model.End, out totalCount); model.TotalCount = totalCount; return View(model); diff --git a/Src/VideoGameQuotes.Web/Global.asax.cs b/Src/VideoGameQuotes.Web/Global.asax.cs index bc44e14..47ca6a0 100644 --- a/Src/VideoGameQuotes.Web/Global.asax.cs +++ b/Src/VideoGameQuotes.Web/Global.asax.cs @@ -77,7 +77,7 @@ namespace VideoGameQuotes.Web { routes.MapRoute("paged", "{action}/{page}", new { controller = "Quote", page = 1 }, new { action = "best|recent", page = @"\d+" }); routes.MapRoute("browse", "browse/{*qualifiers}", new { controller = "Quote", action = "Browse" }); routes.MapRoute("search", "search/{*searchQuery}", new { controller = "Quote", action = "Search" }); - routes.MapRoute("quote-task", "{action}/{id}", new { controller = "Quote" }, new { action = "edit|flags", id = @"\d+" }); + routes.MapRoute("quote-task", "quote/{action}/{id}", new { controller = "Quote" }, new { action = "edit", id = @"\d+" }); routes.MapRoute("quote", "{action}", new { controller = "Quote" }, new { action = "submit|recent|random|vote|report" }); routes.MapRoute("dismiss-flag", "dismiss-flag", new { controller = "Quote", action = "DismissFlag" }); routes.MapRoute("individual-quote", "quote/{id}/{*text}", new { controller = "Quote", action = "Quote" }, new { id = @"\d+" }); diff --git a/Src/VideoGameQuotes.Web/Models/BrowseModel.cs b/Src/VideoGameQuotes.Web/Models/BrowseModel.cs index c4435bb..2f97a5f 100644 --- a/Src/VideoGameQuotes.Web/Models/BrowseModel.cs +++ b/Src/VideoGameQuotes.Web/Models/BrowseModel.cs @@ -11,7 +11,7 @@ namespace VideoGameQuotes.Web.Models { PublisherIds = Enumerable.Empty(); } - public User User { get; set; } + public User CurrentUser { get; set; } public IEnumerable GameIds { get; set; } public IEnumerable SystemIds { get; set; } diff --git a/Src/VideoGameQuotes.Web/Models/QualifiedBrowseModel.cs b/Src/VideoGameQuotes.Web/Models/QualifiedBrowseModel.cs index 049e5c8..7b4d33e 100644 --- a/Src/VideoGameQuotes.Web/Models/QualifiedBrowseModel.cs +++ b/Src/VideoGameQuotes.Web/Models/QualifiedBrowseModel.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using Portoa.Web.Models; using VideoGameQuotes.Api; namespace VideoGameQuotes.Web.Models { @@ -10,8 +10,9 @@ namespace VideoGameQuotes.Web.Models { SortMethod = model.SortMethod; SystemIds = model.SystemIds; SortOrder = model.SortOrder; + CurrentUser = model.CurrentUser; } - public IEnumerable Quotes { get; set; } + public PagedModel PagedModel { get; set; } } } \ No newline at end of file diff --git a/Src/VideoGameQuotes.Web/Services/QuoteService.cs b/Src/VideoGameQuotes.Web/Services/QuoteService.cs index f0016fa..f1ed697 100644 --- a/Src/VideoGameQuotes.Web/Services/QuoteService.cs +++ b/Src/VideoGameQuotes.Web/Services/QuoteService.cs @@ -18,14 +18,12 @@ namespace VideoGameQuotes.Web.Services { Publisher GetPublisher(int id); GamingSystem GetSystem(int systemId); Category GetCategory(int categoryId); - Category SaveCategory(Category category); - IEnumerable GetMostRecentQuotes(int start, int end, out int totalCount); + IEnumerable GetRecentQuotes(int start, int end, out int totalCount); [CanBeNull] Quote GetRandomQuote(); IEnumerable GetBestQuotes(int start, int end, out int totalCount); - Vote SaveVote(Vote vote); Vote GetVoteOrCreateNew(Quote quote, User voter); - IEnumerable GetBrowsableQuotes(BrowseModel model); + IEnumerable GetBrowsableQuotes(BrowseModel model, int start, int end, out int totalCount); } public class QuoteService : IQuoteService { @@ -104,12 +102,7 @@ namespace VideoGameQuotes.Web.Services { } [UnitOfWork] - public Category SaveCategory(Category category) { - return categoryRepository.Save(category); - } - - [UnitOfWork] - public IEnumerable GetMostRecentQuotes(int start, int end, out int totalCount) { + public IEnumerable GetRecentQuotes(int start, int end, out int totalCount) { totalCount = quoteRepository.Records.Count(); return quoteRepository .Records @@ -143,11 +136,6 @@ namespace VideoGameQuotes.Web.Services { .Take(end - start + 1); } - [UnitOfWork] - public Vote SaveVote(Vote vote) { - return voteRepository.Save(vote); - } - [UnitOfWork] public Vote GetVoteOrCreateNew(Quote quote, User voter) { var vote = voteRepository.Records.SingleOrDefault(v => v.Quote == quote && v.Voter == voter); @@ -158,7 +146,7 @@ namespace VideoGameQuotes.Web.Services { } [UnitOfWork] - public IEnumerable GetBrowsableQuotes(BrowseModel model) { + public IEnumerable GetBrowsableQuotes(BrowseModel model, int start, int end, out int totalCount) { var quotes = quoteRepository.Records; if (model.GameIds.Any()) { quotes = quotes.Where(quote => model.GameIds.Contains(quote.Game.Id)); @@ -173,7 +161,8 @@ namespace VideoGameQuotes.Web.Services { quotes = quotes.Where(quote => quote.Categories.Any(category => model.CategoryIds.Contains(category.Id))); } - return quotes; + totalCount = quotes.Count(); + return quotes.Skip(start - 1).Take(end - start + 1); } } } \ No newline at end of file diff --git a/Src/VideoGameQuotes.Web/VideoGameQuotes.Web.csproj b/Src/VideoGameQuotes.Web/VideoGameQuotes.Web.csproj index d1050ae..3c52671 100644 --- a/Src/VideoGameQuotes.Web/VideoGameQuotes.Web.csproj +++ b/Src/VideoGameQuotes.Web/VideoGameQuotes.Web.csproj @@ -150,9 +150,12 @@ + + + diff --git a/Src/VideoGameQuotes.Web/Views/Home/Index.aspx b/Src/VideoGameQuotes.Web/Views/Home/Index.aspx index 6c80f33..5cf4ba0 100644 --- a/Src/VideoGameQuotes.Web/Views/Home/Index.aspx +++ b/Src/VideoGameQuotes.Web/Views/Home/Index.aspx @@ -5,21 +5,22 @@

Welcome

- Welcome to Video Game Quotes. You can <%= Html.ActionLink("browse", "index", "quote") %>, + Welcome to Video Game Quotes. You can <%= Html.ActionLink("browse", "browse", "quote") %>, <%= Html.ActionLink("rate", "best", "quote") %> and <%= Html.ActionLink("submit", "submit", "quote") %> - quotes from video games. You do not need to register or login (in fact, you aren't allowed to) - to perform any of these tasks. Participation is encouraged. + quotes from video games. You do not need to register or login to perform any of these tasks. + Participation is encouraged.

- If you see a quote that is inaccurate, fake, spelled wrong, spam or you're just straight up - concerned about it, please use the report link near the quote in question. It won't - be removed immediately, but it will be flagged for review by our crack team of administrators (i.e. me). + If you see a quote that is inaccurate, fake, spelled wrong, spam or you’re just straight up + concerned about it, please flag () + the quote in question. It won’t be removed immediately, but it will be flagged for review by our + crack team of administrators (i.e. me).

If you have ideas to make this place suck less, or if you just want to express your admiration - for its creator (i.e. me), don't hesitate to contact him (i.e. me) using the + for its creator (i.e. me), don’t hesitate to contact him (i.e. me) using the <%= Html.ActionLink("contact", "contact", "home") %> form.

diff --git a/Src/VideoGameQuotes.Web/Views/Quote/PagingMenu.ascx b/Src/VideoGameQuotes.Web/Views/Quote/PagingMenu.ascx index 14ed87b..8ebb1fd 100644 --- a/Src/VideoGameQuotes.Web/Views/Quote/PagingMenu.ascx +++ b/Src/VideoGameQuotes.Web/Views/Quote/PagingMenu.ascx @@ -1,6 +1,6 @@ <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> -<% if (!Model.HasNext && !Model.HasPrevious) { return; } %> +<% if (!Model.ShouldShowMenu) { return; } %>

- Showing <%= Model.Start %>—<%= Model.ActualEnd %> of <%= Model.TotalCount %>. + <% if (Model.CurrentPageIsValid) { %> + Showing <%= Model.Start%>—<%= Model.ActualEnd%> of <%= Model.TotalCount%>. + <% } else { %> + Nothing to show of <%= Model.TotalCount%>. + <% } %>

\ No newline at end of file diff --git a/Src/VideoGameQuotes.Web/Views/Quote/QualifiedBrowse.aspx b/Src/VideoGameQuotes.Web/Views/Quote/QualifiedBrowse.aspx index d8e5932..9007353 100644 --- a/Src/VideoGameQuotes.Web/Views/Quote/QualifiedBrowse.aspx +++ b/Src/VideoGameQuotes.Web/Views/Quote/QualifiedBrowse.aspx @@ -1,15 +1,18 @@ -<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage" MasterPageFile="~/Views/Shared/Site.Master" %> +<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage" MasterPageFile="~/Views/Shared/Site.Master" %> +<%@ Import Namespace="Portoa.Web.Models" %> <%@ Import Namespace="VideoGameQuotes.Web.Models" %> Browse -

- Here are some quotes -

+ <% Html.RenderPartial("PagingMenu", new PagingMenuModel(Model.PagedModel)); %> <% - foreach (var quote in Model.Quotes) { - Html.RenderPartial("SingleQuote", new QuoteModel { Quote = quote, User = Model.User }); - } + if (Model.PagedModel.TotalCount > 0) { + foreach (var quote in Model.PagedModel.Records) { + Html.RenderPartial("SingleQuote", new QuoteModel { Quote = quote, User = Model.CurrentUser }); + } + } else { %> +

No quotes found.

+ <% } %>
\ No newline at end of file diff --git a/Src/VideoGameQuotes.Web/Views/Shared/Site.Master b/Src/VideoGameQuotes.Web/Views/Shared/Site.Master index 4b41bb4..e34c515 100644 --- a/Src/VideoGameQuotes.Web/Views/Shared/Site.Master +++ b/Src/VideoGameQuotes.Web/Views/Shared/Site.Master @@ -17,7 +17,7 @@