private static void AddTrackPlay(TrackPlay track) { using (var repo = DataAccessContext.GetRepository()) { if (repo.Plays.Count(x => x.DatePlayed == track.DatePlayed) > 0) return; var play = new Play { Id = Guid.NewGuid() }; var t = repo.Tracks.Where(x => x.Name.ToLower() == track.TrackName.ToLower()).Where( x => x.Artist.Name.ToLower() == track.Artist.ToLower()).FirstOrDefault(); if (t == null) return; play.TrackId = t.Id; play.DatePlayed = track.DatePlayed; play.Percentage = 100; repo.Plays.InsertOnSubmit(play); repo.SubmitChanges(); } }
partial void DeletePlay(Play instance);
partial void UpdatePlay(Play instance);
partial void InsertPlay(Play instance);
private void detach_Plays(Play entity) { this.SendPropertyChanging(); entity.Track = null; }
private void attach_Plays(Play entity) { this.SendPropertyChanging(); entity.Track = this; }