예제 #1
0
 public ActionResult HandleTrackUpload(int aId)
 {
     HttpPostedFileBase httpPostedFileBase = base.Request.Files["Filedata"];
     JsonResult jsonResult = new JsonResult();
     string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(httpPostedFileBase.FileName);
     string path = MediaNameGen.GetRandomMediaName() + Path.GetExtension(httpPostedFileBase.FileName);
     if (Path.GetExtension(httpPostedFileBase.FileName).ToLower().Equals(".mp3"))
     {
         string text = Path.Combine(HostingEnvironment.MapPath("~/wMedia/Audio/Uploads"), path);
         httpPostedFileBase.SaveAs(text);
         AudioRepository audioRepository = new AudioRepository(new yslDataContext());
         AudioAlbumItemRepository audioAlbumItemRepository = new AudioAlbumItemRepository(new yslDataContext());
         AudioAlbumRepository audioAlbumRepository = new AudioAlbumRepository(new yslDataContext());
         int audioId = audioRepository.addAudio(new Audio
         {
             AccountId = 1,
             Description = "",
             Title = fileNameWithoutExtension,
             Location = text
         });
         AudioAlbum audioAlbum = audioAlbumRepository.getAudioAlbum(aId);
         int num = audioAlbumItemRepository.addAudioAlbumItem(new AudioAlbumItem
         {
             AudioId = audioId,
             AudioAlbumId = aId,
             Track = audioAlbum.AudioAlbumItems.Count<AudioAlbumItem>() + 1
         });
         string[,] array = new string[1, 3];
         int num2 = 0;
         array[num2, 0] = Url.Content(text);
         array[num2, 1] = fileNameWithoutExtension;
         array[num2, 2] = num.ToString();
         jsonResult.Data =array;
     }
     return jsonResult;
 }