cleanup
This commit is contained in:
parent
cdd93afeff
commit
2496edaf89
@ -47,9 +47,10 @@ namespace VideoGameQuotes.Web.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Recent() {
|
public ActionResult Recent() {
|
||||||
//get last 10 submitted quotes
|
return View(new QuoteCollectionModel {
|
||||||
var quotes = quoteService.GetMostRecentQuotes(10);
|
Quotes = quoteService.GetMostRecentQuotes(10),
|
||||||
return View(new QuoteCollectionModel { Quotes = quotes, User = currentUserProvider.CurrentUser });
|
User = currentUserProvider.CurrentUser
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Best(int start = 0, int end = 19) {
|
public ActionResult Best(int start = 0, int end = 19) {
|
||||||
|
14
Src/VideoGameQuotes.Web/Models/PagedQuoteCollectionModel.cs
Normal file
14
Src/VideoGameQuotes.Web/Models/PagedQuoteCollectionModel.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace VideoGameQuotes.Web.Models {
|
||||||
|
public class PagedQuoteCollectionModel : QuoteCollectionModel {
|
||||||
|
public int Start { get; set; }
|
||||||
|
public int End { get; set; }
|
||||||
|
public int PageSize { get { return End - Start + 1; } }
|
||||||
|
public int NextStart { get { return End + 1; } }
|
||||||
|
public int NextEnd { get { return End + PageSize; } }
|
||||||
|
public int PreviousStart { get { return Math.Max(0, Start - PageSize); } }
|
||||||
|
public int PreviousEnd { get { return Math.Max(PageSize - 1, End - PageSize); } }
|
||||||
|
public bool HasPrevious { get { return Start > 0; } }
|
||||||
|
}
|
||||||
|
}
|
9
Src/VideoGameQuotes.Web/Models/QuoteCollectionModel.cs
Normal file
9
Src/VideoGameQuotes.Web/Models/QuoteCollectionModel.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using VideoGameQuotes.Api;
|
||||||
|
|
||||||
|
namespace VideoGameQuotes.Web.Models {
|
||||||
|
public class QuoteCollectionModel {
|
||||||
|
public IEnumerable<Quote> Quotes { get; set; }
|
||||||
|
public User User { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,36 +1,12 @@
|
|||||||
using System;
|
using JetBrains.Annotations;
|
||||||
using System.Collections.Generic;
|
|
||||||
using JetBrains.Annotations;
|
|
||||||
using VideoGameQuotes.Api;
|
using VideoGameQuotes.Api;
|
||||||
|
|
||||||
namespace VideoGameQuotes.Web.Models {
|
namespace VideoGameQuotes.Web.Models {
|
||||||
public class QuoteCollectionModel {
|
|
||||||
public IEnumerable<Quote> Quotes { get; set; }
|
|
||||||
public User User { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class PagedQuoteCollectionModel : QuoteCollectionModel {
|
|
||||||
public int Start { get; set; }
|
|
||||||
public int End { get; set; }
|
|
||||||
public int PageSize { get { return End - Start + 1; } }
|
|
||||||
public int NextStart { get { return End + 1; } }
|
|
||||||
public int NextEnd { get { return End + PageSize; } }
|
|
||||||
public int PreviousStart { get { return Math.Max(0, Start - PageSize); } }
|
|
||||||
public int PreviousEnd { get { return Math.Max(PageSize - 1, End - PageSize); } }
|
|
||||||
public bool HasPrevious { get { return Start > 0; } }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class QuoteModel {
|
public class QuoteModel {
|
||||||
[NotNull]
|
[NotNull]
|
||||||
public Quote Quote { get; set; }
|
public Quote Quote { get; set; }
|
||||||
public User User { get; set; }
|
public User User { get; set; }
|
||||||
|
public bool VotedUp { get { return Quote.VotedFor(User) == VoteDirection.Up; } }
|
||||||
public bool VotedUp {
|
public bool VotedDown { get { return Quote.VotedFor(User) == VoteDirection.Down; } }
|
||||||
get { return Quote.VotedFor(User) == VoteDirection.Up; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool VotedDown {
|
|
||||||
get { return Quote.VotedFor(User) == VoteDirection.Down; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -23,7 +23,6 @@ namespace VideoGameQuotes.Web.Services {
|
|||||||
Quote GetRandomQuote();
|
Quote GetRandomQuote();
|
||||||
IEnumerable<Quote> GetBestQuotes(int start, int end);
|
IEnumerable<Quote> GetBestQuotes(int start, int end);
|
||||||
Vote SaveVote(Vote vote);
|
Vote SaveVote(Vote vote);
|
||||||
[NotNull]
|
|
||||||
Vote GetVoteOrCreateNew(Quote quote, User voter);
|
Vote GetVoteOrCreateNew(Quote quote, User voter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +85,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Controllers\HomeController.cs" />
|
<Compile Include="Controllers\HomeController.cs" />
|
||||||
|
<Compile Include="Models\PagedQuoteCollectionModel.cs" />
|
||||||
|
<Compile Include="Models\QuoteCollectionModel.cs" />
|
||||||
<Compile Include="Models\QuoteModel.cs" />
|
<Compile Include="Models\QuoteModel.cs" />
|
||||||
<Compile Include="Models\VoteModel.cs" />
|
<Compile Include="Models\VoteModel.cs" />
|
||||||
<Compile Include="Validation\NonEmptyText.cs" />
|
<Compile Include="Validation\NonEmptyText.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user