Beispiel #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;
 }
Beispiel #2
0
 public ActionResult UpdateTracks(int aId, string TrackList)
 {
     AudioRepository audioRepository = new AudioRepository(new yslDataContext());
     AudioAlbumItemRepository audioAlbumItemRepository = new AudioAlbumItemRepository(new yslDataContext());
     try
     {
         List<AudioAlbumItem> allAudioAlbumItemsForAlbum = audioAlbumItemRepository.getAllAudioAlbumItemsForAlbum(aId);
         ListOfTracks listOfTracks = JsonConvert.DeserializeObject<ListOfTracks>(TrackList);
         using (List<AudioAlbumItem>.Enumerator enumerator = allAudioAlbumItemsForAlbum.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 AudioAlbumItem item = enumerator.Current;
                 try
                 {
                     Tracks tracks = listOfTracks.tracks.Single((Tracks a) => a.audioAlbumItemId == item.AudioAlbumItemId);
                     item.Track = tracks.Number;
                     Audio audio = item.Audio;
                     audio.Title = tracks.Title;
                     audioAlbumItemRepository.updateAudioAlbumItem(item);
                     audioRepository.updateAudio(audio);
                 }
                 catch (Exception)
                 {
                     audioAlbumItemRepository.deleteAudioAlbumItem(item);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     JsonResult jsonResult = new JsonResult();
     jsonResult.Data ="hereeee";
     return jsonResult;
 }
Beispiel #3
0
 public AudioAlbumItemModel getAudioAlbumItemAsModel(AudioAlbumItem item)
 {
     AudioRepository audioRepository = new AudioRepository(new yslDataContext());
     return new AudioAlbumItemModel
     {
         audioAlbumItemId = item.AudioAlbumItemId,
         trackNumber = item.Track,
         audio = audioRepository.convertAudioToModel(item.Audio)
     };
 }