/// <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 voteinProgressAudioBattles = new RapBattleAudio(); var dataSource = voteinProgressAudioBattles.GetVotingInProgressBattles().Cast<RapBattleAudio>().ToList(); this.VotingProgressAudioBattlesRepeater.DataSource = dataSource; this.VotingProgressAudioBattlesRepeater.DataBind(); }
/// <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 newAudioBattles = new RapBattleAudio(); var dataSource = newAudioBattles.GetLatestBattles().Cast<RapBattleAudio>().ToList(); this.NewAudioBattlesRepeater.DataSource = dataSource; this.NewAudioBattlesRepeater.DataBind(); }
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); }
public HttpResponseMessage Get(int id) { var pageUserId = RapContextFacade.Current.GetUserId(); this._audioBattle = new RapBattleAudio(pageUserId, id).GetSettings() as RapBattleAudio; var builtObj = new AudioBattleFactory().Construct(this._audioBattle); return Request.CreateResponse(HttpStatusCode.OK, builtObj); }
/// <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]; this._battle = new RapBattleAudio(this.PageContext.PageUserID, Convert.ToInt32(query)); this.AudioBattleCommentsPager.Dt = this._battle.GetBattleComments(); this.AudioBattleCommentsPager.Repeater = this.AudioBattleFeed; this.AudioBattleCommentsPager.PerPage = 10; this.PostEdit.PostBtn.Click += PostComment_Click; }
protected override void OnInit([NotNull] EventArgs e) { this.RegisterJs(); this.BattleId = this.GetService<UrlProvider>().GetQuery()[0]; //for silverlight application initialization initParams.Attributes.Add("value", string.Format("userId={0},battleId={1}, address={2}", this.PageContext.PageUserID, this.BattleId, this.GetService<ApplicationProvider>().GetApplicationSettings("YAF.BaseUrlMask"))); this.Battle = new RapBattleAudio(this.PageContext.PageUserID, Convert.ToInt32(this.BattleId)).GetSettings() as RapBattleAudio; var ui = this.GetFactory<ASPNetAudioBattleFactory>().Build(this.Battle); this.JoinButton.CommandArgument = ui.Join.CommandArgument; this.JoinButton.Hidden = ui.Join.Hidden; this.TimerIcon.Icon = ui.TimerIcon.Icon; this.AudioTimer.TimeToEnd = ui.Timer.TimeToEnd; this.BattleUser1.UserId = ui.User1.UserId; this.BattleUser2.UserId = ui.User2.UserId; this.ListenerAudio.Battle = this.Battle; this.BattleUser2.Visible = ui.User2.Visible; this.JoinButton.OnClientClick += "return handlepostback({0})".FormatWith(this.JoinButton.ClientID); this.silverlightappbody.Visible = false; if (this.IsMobile) { if ((this.Battle.UserId1 == this.PageContext.PageUserID && this.Battle.User1Audio.IsNotSet()) || (this.Battle.UserId2 == this.PageContext.PageUserID) && this.Battle.User2Audio.IsNotSet()) { this.NoSilverlight.Controls.Add(new Label { Html = this.Text("REQUIRED", "SILVERLIGHT") }); } } else { if ((this.Battle.UserId1 == this.PageContext.PageUserID && this.Battle.User1Audio.IsNotSet()) || (this.Battle.UserId2 == this.PageContext.PageUserID) && this.Battle.User2Audio.IsNotSet()) { this.silverlightappbody.Visible = true; } } 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; } }
public HttpResponseMessage Join(AudioBattleModel value) { //TODO more validation if its a valid battle that a user can join such as end date Contract.Requires(value != null); var pageUserId = value.PageUserId; this._audioBattle = new RapBattleAudio(value.PageUserId, value.BattleId).GetSettings() as RapBattleAudio; if (this._audioBattle.UserId1 == pageUserId || this._audioBattle.UserId2 == pageUserId || (RapContextFacade.Current.GetUserId() != pageUserId)) { return Request.CreateResponse(HttpStatusCode.BadRequest); } this._audioBattle.JoinBattle(value.PageUserId); return Request.CreateResponse(HttpStatusCode.Created); }
public HttpResponseMessage Submit(AudioBattleDspModel recordedAudio) { //TODO more validation here Contract.Requires(recordedAudio != null); this._audioBattle = new RapBattleAudio(recordedAudio.PageUserId, recordedAudio.BattleId).GetSettings() as RapBattleAudio; if (this._audioBattle.Beat == null) { this._audioBattle.Beat = recordedAudio.Beat; } if (this._audioBattle.PageUserId != RapContextFacade.Current.GetUserId() && this._audioBattle.UserId1 != this._audioBattle.PageUserId && this._audioBattle.UserId1 != this._audioBattle.PageUserId) { return Request.CreateResponse(HttpStatusCode.BadRequest); } var signal = new RapSignalProcessing(recordedAudio.RecordedFileLocation, (int) recordedAudio.Beat); this._audioBattle.Submit(recordedAudio.PageUserId, recordedAudio.RequiresDspEngineering ? signal.CombineAudioSignal() : recordedAudio.RecordedFileLocation); //TODO might not be neccessary to get settings again return Request.CreateResponse(HttpStatusCode.Created); }
/// <summary> /// Gets the rankings. /// </summary> /// <returns></returns> /// <exception cref="System.NotImplementedException"></exception> public override List<BattleRanking> GetRankings() { var allAudioBattles = new RapBattleAudio().GetAllBattles(RapBattleType.Audio); var sortedBattles = this.SortBattles(allAudioBattles); return this.GetTopRankings(sortedBattles); }