コード例 #1
0
        public EditAlbumViewModel GetEditAlbumViewModel(int id)
        {
            EditAlbumViewModel editAlbum = Mapper.Map <Album, EditAlbumViewModel>(albumDomainService.GetAlbumById(id));

            editAlbum.SelectListSingers = new SelectList(singerDomainService.GetListSingers(), "Id", "Name");

            return(editAlbum);
        }
コード例 #2
0
        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();
        }