public async Task <Artist> GetArtist(Spotify sp, SpotterAzure_dbContext dbContext) { IQueryable <Artist> artists = dbContext.Artists.Where(x => x.ArtistId == this.ArtistId); if (artists.Any()) { artists.First().GetArtist(sp, dbContext); return(artists.First()); } else { Artist art = new Artist(this, sp); return(art); } }
public async Task <ArtistDetails> GetArtist(Spotify sp, SpotterAzure_dbContext dbContext) { if (DateTime.Now.AddDays(-7) > this.TrueAt.Value || this.Details == null) { try { FullArtist features = await sp.spotify.Artists.Get(this.ArtistId); this.Details = JObject.FromObject(features).ToString(); dbContext.Update(this); } catch { return(null); } } return(JObject.Parse(this.Details).ToObject <ArtistDetails>()); }
public async Task <Features> GetFeatures(Spotify sp, SpotterAzure_dbContext dbContext) { if (DateTime.Now.AddDays(-7) > this.TrueAt.Value || this.Features == null) { try { TrackAudioFeatures features = await sp.spotify.Tracks.GetAudioFeatures(TrackId); this.Features = JObject.FromObject(features).ToString(); } catch { return(null); } finally { dbContext.Tracks.Update(this); } } return(JObject.Parse(this.Features).ToObject <Features>()); }
public int RecentSkips(string trackid, int hours, SpotterAzure_dbContext dbContext) { DateTime After = DateTime.Now.AddHours(-hours); return(dbContext.Skips.Count(x => x.TrackId == trackid && x.SpotId == SpotId && x.SkipAt > After)); }