Exemple #1
0
        public static MusicBrainzArtistCredit Map(DataContext context, JsonMusicBrainzRequest.ClaArtistCredit json)
        {
            MusicBrainzArtistCredit credit = new MusicBrainzArtistCredit
            {
                Name         = json.Name
                , Joinphrase = json.Joinphrase
                , Artist     = null == json.Artist ? null : Map(context, json.Artist)
            };

            credit.UniqueHash = Comparator.ComputeContentHash(credit);

            MusicBrainzArtistCredit dbCredit =
                context.SetArtistCredits.FirstOrDefault(x => x.UniqueHash.Equals(credit.UniqueHash));

            if (null != dbCredit)
            {
                // already in db
                return(dbCredit);
            }

            context.SetArtistCredits.Add(credit);
            context.SaveChanges();

            return(credit);
        }
Exemple #2
0
 public static MusicBrainzArtistCreditMusicBrainzRecord NewShadow(MusicBrainzRecord record
                                                                  , MusicBrainzArtistCredit artistCredit)
 {
     return(new MusicBrainzArtistCreditMusicBrainzRecord
     {
         MusicBrainzRecord = record
         , MusicBrainzRecordUniqueId = record.UniqueId
         , MusicBrainzArtistCredit = artistCredit
         , MusicBrainzArtistCreditUniqueId = artistCredit.UniqueId
     });
 }
Exemple #3
0
 private static MusicBrainzReleaseMusicBrainzArtistCredit NewShadow(MusicBrainzRelease release
                                                                    , MusicBrainzArtistCredit artistCredit)
 {
     return(new MusicBrainzReleaseMusicBrainzArtistCredit
     {
         MusicBrainzRelease = release
         , MusicBrainzReleaseUniqueId = release.UniqueId
         , MusicBrainzArtistCredit = artistCredit
         , MusicBrainzArtistCreditUniqueId = artistCredit.UniqueId
     });
 }
Exemple #4
0
 public static Dictionary <String, Object> ToJsonDictionary(this MusicBrainzArtistCredit ac)
 {
     return(new Dictionary <String, Object>
     {
         {
             "Joinphrase", ac.Joinphrase
         }
         ,
         {
             "Artist", ac.Artist?.ToJsonDictionary()
         }
     });
 }