コード例 #1
0
 /// <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")));
     }
 }