public static List<TeamLogo> GetAllLogos() { try { var cached = GetCache(HttpContext.Current.Cache); if (cached.Logos == null || cached.Logos.Count == 0) { TeamFactory lo = new TeamFactory(); var logos = lo.GetAllLogos(new TeamDisplay()); foreach (var l in logos) l.SaveLocation = null; cached.Logos = logos; UpdateCache(cached); } return cached.Logos; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return new List<TeamLogo>(); }
private static ApiCache GetCache(System.Web.Caching.Cache cache) { try { ApiCache dataObject = (ApiCache)cache["ApiCache"]; if (dataObject == null) { dataObject = (ApiCache)cache["ApiCache"]; if (dataObject == null) { dataObject = new ApiCache(); TeamFactory lo = new TeamFactory(); dataObject.Countries = new List<CountryClass>(); TeamDisplay team = new TeamDisplay(); var logos = lo.GetAllLogos(team); foreach (var l in logos) l.SaveLocation = null; dataObject.Logos = logos; var scoreboardLogos = team.ScoreboardLogos; foreach (var l in scoreboardLogos) l.SaveLocation = null; dataObject.ScoreboardLogos = scoreboardLogos; cache["ApiCache"] = dataObject; } } return dataObject; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return null; }