public void AddTrack(CreateTrackViewModel trackModel, HttpServerUtilityBase server)
        {
            Track track = Mapper.Map <CreateTrackViewModel, Track>(trackModel);

            track.Singer  = singerDomainService.GetSingerById(trackModel.SingerId);
            track.Album   = albumDomainService.GetAlbumById(trackModel.AlbumId);
            track.Genre   = genreDomainService.GetGenreById(trackModel.GenreId);
            track.Popular = popularDomainService.GetPopularById(trackModel.PopularId);
            track.Novelty = noveltyDomainService.GetNoveltyById(trackModel.NoveltyId);

            track.TrackImage.ImageData = GetArray(trackModel.TrackImage);

            trackModel.PlaylistArrayId
            .ForEach(x => track.Playlists.Add(playlistDomainService.GetPlaylistById(x)));

            string name = trackModel.TrackFile.FileName;

            trackModel.TrackFile.SaveAs(server.MapPath(PathServerBefore + name));
            track.TrackFile.FileLocation = PathServerAfter + name;

            trackDomainService.Entry(track).State = EntityState.Added;
            trackDomainService.SaveChanges();
        }
Example #2
0
 public DeletePlaylistViewModel GetDeletePlaylistViewModel(int id)
 {
     return(Mapper.Map <Playlist, DeletePlaylistViewModel>(playlistDomainService.GetPlaylistById(id)));
 }