示例#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;
 }
示例#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;
 }
示例#3
0
 public AudioAlbumDataForJSON getLatestSingle(int artistId)
 {
     var pRepo = new PhotoRepository(new yslDataContext());
     var aRepo = new AudioAlbumItemRepository(new yslDataContext());
     AudioAlbumDataForJSON result;
     try
     {
         List<AudioAlbumDataForJSON> source = (
             from b in this.db.AudioAlbums
             where b.ArtistId == artistId
             select b into s
             orderby s.Created descending
             select s).Join(this.db.Photos, (AudioAlbum a) => a.PhotoId, (Photo p) => p.PhotoId, (AudioAlbum, Photo) => new AudioAlbumDataForJSON { artist = AudioAlbum.Artist.Name, audioAlbumId = AudioAlbum.AudioAlbumId, photo = pRepo.getPhotoAsModel(Photo), title = AudioAlbum.Title, tracks = aRepo.getAudioAlbumItemAsModel(AudioAlbum.AudioAlbumItems.ToList()) }).ToList<AudioAlbumDataForJSON>();
         result = source.First<AudioAlbumDataForJSON>();
     }
     catch
     {
         result = new AudioAlbumDataForJSON();
     }
     return result;
 }