/// <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) { this._verse = this.GetCore<RapAudioVerses>(); this._verse.UserId = this.UserId; this.AudioVersesPager.PerPage = 6; this.AudioVersesPager.GridView = this.AudioVersesGV; var usersVerses = this._verse.GetVerses(this.UserId); this.AudioVersesPager.ListDs = usersVerses.Cast<object>().ToList(); this.AudioVersesCount = usersVerses.Count; if (this.AudioVersesCount <= 0) { var noVerses = this.GetCore<CalloutBox>() .Create(BootstrapElementType.Info, this.Text("VERSES", "NO_AUDIO")); this.NoAudioVerses.Controls.Add(noVerses); } }
/// <summary> /// Handles the Click event of the SubmitAudioVerse control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="eventArgs">The <see cref="EventArgs"/> instance containing the event data.</param> protected void SubmitAudioVerse_Click([NotNull] object sender,[NotNull] EventArgs eventArgs) { if (this.VerseTitleAudio.Value.IsNotSet()) { this.PageContext.AddLoadMessage(this.Text("VERSES", "NO_TITLE")); return; } if (this.VerseUploader.PostedFile.FileName.IsNotSet()) { this.PageContext.AddLoadMessage(this.Text("VERSES", "NO_CONTENT")); return; } if (this.VerseUploader.PostedFile.ContentType.Contains("audio")) { if (this.VerseUploader.PostedFile.ContentLength < 3242880) { var fileAudioVerse = Guid.NewGuid() + Path.GetExtension(this.VerseUploader.FileName); var path = this.GetService<ResourceProvider>().GetPath(RapResource.AudioVerses, fileAudioVerse); this.VerseUploader.PostedFile.SaveAs(path); var a = new RapAudioVerses(this.PageContext.PageUserID); a.AddVerse(this.VerseTitleAudio.Value, fileAudioVerse); this.AddLoadMessageSession(this.Text("VERSES", "SUCCESS")); this.GetService<UrlProvider>().RefreshPage(); } else { this.PageContext.AddLoadMessage(this.Text("COMMON", "COMMON_MUSICEERROR") .FormatWith(this.Text("MUSIC", "ERROR_FORMAT").FormatWith("mp3")), MessageTypes.Error); } } else { this.PageContext.AddLoadMessage(this.Text("COMMON", "COMMON_MUSICEERROR") .FormatWith(this.Text("MUSIC", "ERROR_MISSING"))); } }
public HttpResponseMessage GetAudioVerse(int id) { var file = new RapAudioVerses().GetAudioVersePath(id); var path = HttpContext.Current.Server.MapPath("~/Uploads/AudioVerses/" + file); return RapFileStreamPlayer.Get(path); }