Example #1
0
 public void UpdatePlaylist(Playlist playlist, AlbumPlaylist albumPlay)
 {
     playlist.AlbumPlaylists.Add(albumPlay);
     _context.Entry(playlist).State = EntityState.Modified;
     _context.Entry(playlist).Property(p => p.OwnerID).IsModified = false;
     _context.Entry(playlist).Property(p => p.Name).IsModified    = false;
     _context.SaveChanges();
 }
Example #2
0
    /// <summary>
    /// トラック情報からアルバム情報を生成する
    /// </summary>
    /// <param name="id">アルバムID</param>
    /// <param name="key">アルバムキー</param>
    /// <param name="track">トラック情報</param>
    public AlbumInfo(int id, string key, Track track, string artworkId)
    {
        this.Id              = id;
        this.Key             = key;
        this.Name            = track.Album;
        this.Artist          = track.GetAlbumArtist();
        this.IsCompilation   = track.GetIsCompiatilnAlbum();
        this.ArtworkId       = artworkId;
        this.RegisteredAt    = DateTimeOffset.Now;
        this.UpdatedAt       = this.RegisteredAt;
        this._isArtworkFound = artworkId != null;

        this.Playlist = new AlbumPlaylist(this);
    }
Example #3
0
    /// <summary>
    /// DBのモデルデータからアルバム情報を生成する
    /// </summary>
    /// <param name="album">アルバム情報</param>
    /// <param name="artwork">アートワーク情報</param>
    public AlbumInfo(AlbumDataModel album, AlbumArtworksDataModel artwork)
    {
        this.Key             = album.Key;
        this.Id              = album.Id;
        this.Name            = album.Name;
        this.Artist          = album.Artist;
        this.ArtworkId       = album.ArtworkId;
        this.IsCompilation   = album.IsCompilation ?? false;
        this.RegisteredAt    = album.CreatedAt;
        this.UpdatedAt       = album.UpdatedAt;
        this._isArtworkFound = album.ArtworkId != null;

        this.Playlist = new AlbumPlaylist(this);
    }
Example #4
0
        public IActionResult AddToPlaylist(int id, Playlist playlist)
        {
            Album    album     = _context.Albums.Single(a => a.AlbumID == id);
            Playlist playlist2 = _context.Playlists.Single(p => p.PlaylistID == playlist.PlaylistID);

            AlbumPlaylist albumPlaylist = new AlbumPlaylist();

            albumPlaylist.AlbumID    = album.AlbumID;
            albumPlaylist.PlaylistID = playlist.PlaylistID;
            _context.AlbumPlaylists.Add(albumPlaylist);
            UpdateAlbum(album, albumPlaylist);
            UpdatePlaylist(playlist2, albumPlaylist);
            _context.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #5
0
 /// <summary>AlbumPlaylist同士の比較を行う</summary>
 /// <param name="x">左辺</param>
 /// <param name="y">右辺</param>
 /// <returns>比較結果</returns>
 public int Compare(AlbumPlaylist x, AlbumPlaylist y)
 {
     return(_stringComparer.Compare(x.Album.Key, y.Album.Key));
 }
Example #6
0
 public void UpdateAlbum(Album album, AlbumPlaylist albumPlay)
 {
     album.AlbumPlaylists.Add(albumPlay);
     _context.Entry(album).State = EntityState.Modified;
     _context.SaveChanges();
 }