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); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { var query = this.GetService<UrlProvider>().GetQuery(); this._battle = new RapBattleWritten(this.PageContext.PageUserID, Convert.ToInt32(query[0])); this.WrittenBattleCommentsPager.Dt = this._battle.GetBattleComments(); this.WrittenBattleCommentsPager.Repeater = this.WrittenBattleFeed; this.WrittenBattleCommentsPager.PerPage = 10; this.PostEdit.PostBtn.Click += PostComment_Click; }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { IsNotVisible = false; var newWrittenBattles = new RapBattleWritten(); var dataSource = newWrittenBattles.GetVotingInProgressBattles().Cast<RapBattleWritten>().ToList(); this.VotingProgressWrittenBattlesRepeater.DataSource = dataSource; this.VotingProgressWrittenBattlesRepeater.DataBind(); if (dataSource.Count < 1) { IsNotVisible = true; } }
protected override void OnInit([NotNull] EventArgs e) { this.GetService<ClientProviders>() .RegisterClientScriptBlock(this, "fullRapBattleRating", "~/js/RapBattleRating.js", true); this.GetService<ClientProviders>() .RegisterClientScriptBlock(this, "writtenBattleApp", "~/js/WrittenBattles.js", true); this.Id = Convert.ToInt32(this.GetService<UrlProvider>().GetQuery()[0]); this.Battle = new RapBattleWritten(this.PageContext.PageUserID, Id).GetSettings() as RapBattleWritten; this.BarLength = Convert.ToInt32( this.GetService<ApplicationProvider>().GetApplicationSettings("RAP.WrittenBattleBarLength")); this.WrittenVoteDisplay.BattleType = RapBattleType.Written; var ui = this.GetFactory<ASPNetWrittenBattleFactory>().Build(this.Battle); this.BattleJoin2.CommandArgument = ui.Join.CommandArgument; this.BattleJoin2.Hidden = ui.Join.Hidden; this.WrittenTimer.TimeToEnd = ui.Timer.TimeToEnd; this.TimerIcon.Icon = ui.TimerIcon.Icon; this.BattleUser1.UserId = ui.User1.UserId; this.BattleUser2.UserId = ui.User2.UserId; this.BattleUser2.Visible = ui.User2.Visible; this.BattleTextArea1.Attributes.Add("rows", this.Battle.Length.ToString()); this.BattleTextArea2.Attributes.Add("rows", this.Battle.Length.ToString()); this.BattleTextArea1.Value = ui.Verse1.Text; this.BattleTextArea1.Disabled = ui.Verse1.Disabled; this.BattleTextArea2.Value = ui.Verse2.Text; this.BattleTextArea2.Disabled = ui.Verse2.Disabled; this.BattleSubmit1.CommandArgument = ui.User1Submit.CommandArgument; this.BattleSubmit2.CommandArgument = ui.User2Submit.CommandArgument; this.BattleSubmit1.Hidden = ui.User1Submit.Hidden; this.BattleSubmit2.Hidden = ui.User2Submit.Hidden; this.BattleSubmit1.OnClientClick += "return handlepostback({0})".FormatWith(this.BattleSubmit1.ClientID); this.BattleSubmit2.OnClientClick += "return handlepostback({0})".FormatWith(this.BattleSubmit2.ClientID); this.BattleJoin2.OnClientClick += "return handlepostback({0})".FormatWith(this.BattleJoin2.ClientID); this.HandleBattleDateTime(); this.InitializeGraph(); this.HandleWinner(); this.HandleVoting(Battle.UserId1, Battle.UserId2 != null ? (int) Battle.UserId2 : 0); base.OnInit(e); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { var query = this.GetService<UrlProvider>().GetQuery()[0]; RapBattle battle; switch (BattleType) { case RapBattleType.Written: battle = new RapBattleWritten(this.PageContext.PageUserID, Convert.ToInt32(query)); SqlColumnIdTag = "WrittenBattleRatingID"; break; case RapBattleType.Audio: battle = new RapBattleAudio(this.PageContext.PageUserID, Convert.ToInt32(query)); SqlColumnIdTag = "AudioBattleRatingID"; break; case RapBattleType.Video: battle = null; break; default: throw new ArgumentOutOfRangeException(); } var votes = battle.GetVotes(); if (votes.Rows.Count > 0) { foreach (DataRow dr in votes.Rows) { this.DisplayName1 = UserMembershipHelper.GetDisplayNameFromID(Convert.ToInt32(dr["UserID1"])); this.DisplayName2 = UserMembershipHelper.GetDisplayNameFromID(Convert.ToInt32(dr["UserID2"])); } this.VoteDisplay.DataSource = votes; this.VoteDisplay.DataBind(); } else { this.Visible = false; } }
/// <summary> /// Gets the rankings. /// </summary> /// <returns></returns> /// <exception cref="System.NotImplementedException"></exception> public override List<BattleRanking> GetRankings() { var allWrittenBattles = new RapBattleWritten().GetAllBattles(RapBattleType.Written); var sortedBattles = this.SortBattles(allWrittenBattles); return this.GetTopRankings(sortedBattles); }