Permalink
Browse files

updating version to use dimension

  • Loading branch information...
1 parent ae3dacb commit dbb0d9d2d8f2d3e05b966422985d202a9a7422ea @Jetski5822 committed Aug 28, 2011
Showing with 13 additions and 4 deletions.
  1. +5 −2 Controllers/VoteController.cs
  2. +2 −2 Drivers/FavoritePartDriver.cs
  3. +5 −0 Models/Constants.cs
  4. +1 −0 NGM.Favorite.csproj
@@ -32,13 +32,16 @@ public class VoteController : Controller {
if (currentUser == null)
return this.RedirectLocal(returnUrl, "~/");
- var currentVote = _votingService.Get(vote => vote.Username == currentUser.UserName && vote.ContentItemRecord == content.Record && vote.Dimension == "Favorite").FirstOrDefault();
+ var currentVote = _votingService.Get(vote =>
+ vote.Username == currentUser.UserName &&
+ vote.ContentItemRecord == content.Record &&
+ vote.Dimension == Constants.Dimension).FirstOrDefault();
if (currentVote != null) {
_votingService.RemoveVote(currentVote);
}
else {
- _votingService.Vote(content, currentUser.UserName, HttpContext.Request.UserHostAddress, 1, "Favorite");
+ _votingService.Vote(content, currentUser.UserName, HttpContext.Request.UserHostAddress, 1, Constants.Dimension);
}
return this.RedirectLocal(returnUrl, "~/");
@@ -31,10 +31,10 @@ public class FavoritePartDriver : ContentPartDriver<FavoritePart> {
var currentUser = _orchardServices.WorkContext.CurrentUser;
if (currentUser != null) {
- var resultRecord = _votingService.GetResult(part.ContentItem.Id, "sum", "Favorite");
+ var resultRecord = _votingService.GetResult(part.ContentItem.Id, "sum", Constants.Dimension);
part.IsFavorite = (resultRecord != null && resultRecord.Value > 0.0);
- part.NumberOfFavorites = _votingService.Get(vote => vote.Username == currentUser.UserName && vote.Dimension == "Favorite").Sum(o => o.Value);
+ part.NumberOfFavorites = _votingService.Get(vote => vote.Username == currentUser.UserName && vote.Dimension == Constants.Dimension).Sum(o => o.Value);
}
return part;
View
@@ -0,0 +1,5 @@
+namespace NGM.Favorite.Models {
+ public static class Constants {
+ public const string Dimension = "Favotite";
+ }
+}
View
@@ -54,6 +54,7 @@
<Compile Include="Controllers\VoteController.cs" />
<Compile Include="Drivers\FavoritePartDriver.cs" />
<Compile Include="Handlers\FavoritePartHandler.cs" />
+ <Compile Include="Models\Constants.cs" />
<Compile Include="Settings\FavoriteTypePartSettings.cs" />
<Compile Include="Models\FavoritePart.cs" />
<Compile Include="Migrations.cs" />

0 comments on commit dbb0d9d

Please sign in to comment.