public HttpResponseMessage Vote(int id, BattleVoteModel vote)
 {
     Contract.Requires(vote != null);
     var pageUserId = UserData.GetUserIdFromDisplayName(HttpContext.Current.User.Identity.Name);
     var vote1 = new RapBattleVote();
     var vote2 = new RapBattleVote();
     vote1.UserId = vote.UserId1;
     vote1.Flow = vote.User1Flow;
     vote1.Metaphores = vote.User1Metaphores;
     vote1.Multis = vote.User1Multis;
     vote1.PunchLines = vote.User1Punchlines;
     vote1.Wordplay = vote.User1Wordplay;
     vote2.UserId = vote.UserId2;
     vote2.Flow = vote.User2Flow;
     vote2.Metaphores = vote.User2Metaphores;
     vote2.Multis = vote.User2Multis;
     vote2.PunchLines = vote.User2Punchlines;
     vote2.Wordplay = vote.User2Wordplay;
     switch (vote.BattleType)
     {
         case RapBattleType.Written:
         {
             var writtenBattle = new RapBattleWritten(pageUserId, id).GetSettings() as RapBattleWritten;
             writtenBattle.Vote(vote1, vote2);
         }
             break;
         case RapBattleType.Audio:
             var audioBattle = new RapBattleAudio(pageUserId, id).GetSettings() as RapBattleAudio;
             audioBattle.Vote(vote1, vote2);
             break;
     }
     return Request.CreateResponse(HttpStatusCode.NoContent);
 }
Esempio n. 2
0
 /// <summary>
 ///     Votes the specified user.
 /// </summary>
 /// <param name="user1">The user1.</param>
 /// <param name="user2">The user2.</param>
 public void Vote(RapBattleVote user1, RapBattleVote user2)
 {
     if (PageUserId == user1.UserId || PageUserId == user2.UserId)
     {
         return;
     }
     if (this.IsUserAllowedToVote(!HttpContext.Current.User.Identity.IsAuthenticated))
     {
         Db.add_writtenbattle_rating(this.BattleId, this.PageUserId, user1.Wordplay, user2.Wordplay,
             user1.Metaphores, user2.Metaphores, user1.Flow, user2.Flow, user1.Multis, user2.Multis,
             user1.PunchLines,
             user2.PunchLines);
     }
 }