cleanup
This commit is contained in:
parent
cdd93afeff
commit
2496edaf89
@ -47,9 +47,10 @@ namespace VideoGameQuotes.Web.Controllers {
|
||||
}
|
||||
|
||||
public ActionResult Recent() {
|
||||
//get last 10 submitted quotes
|
||||
var quotes = quoteService.GetMostRecentQuotes(10);
|
||||
return View(new QuoteCollectionModel { Quotes = quotes, User = currentUserProvider.CurrentUser });
|
||||
return View(new QuoteCollectionModel {
|
||||
Quotes = quoteService.GetMostRecentQuotes(10),
|
||||
User = currentUserProvider.CurrentUser
|
||||
});
|
||||
}
|
||||
|
||||
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 System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using JetBrains.Annotations;
|
||||
using VideoGameQuotes.Api;
|
||||
|
||||
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 {
|
||||
[NotNull]
|
||||
public Quote Quote { get; set; }
|
||||
public User User { get; set; }
|
||||
|
||||
public bool VotedUp {
|
||||
get { return Quote.VotedFor(User) == VoteDirection.Up; }
|
||||
}
|
||||
|
||||
public bool VotedDown {
|
||||
get { return Quote.VotedFor(User) == VoteDirection.Down; }
|
||||
}
|
||||
public bool VotedUp { 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();
|
||||
IEnumerable<Quote> GetBestQuotes(int start, int end);
|
||||
Vote SaveVote(Vote vote);
|
||||
[NotNull]
|
||||
Vote GetVoteOrCreateNew(Quote quote, User voter);
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,8 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Models\PagedQuoteCollectionModel.cs" />
|
||||
<Compile Include="Models\QuoteCollectionModel.cs" />
|
||||
<Compile Include="Models\QuoteModel.cs" />
|
||||
<Compile Include="Models\VoteModel.cs" />
|
||||
<Compile Include="Validation\NonEmptyText.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user