public IReadOnlyCollection <SuperheroModel> Get() { return(repository.GetAll() .Select(h => new SuperheroModel { Id = h.Id, CombatPower = h.CombatPower, Name = h.Name, Superpower = h.Superpower }).ToList().AsReadOnly()); }
private void ValidateCache() { if (_cachedItems == null || !IsCacheValid) { try { _cachedItems = _superheroRepository.GetAll(); _dataDateTime = DateTime.Now; } catch { _cachedItems = new List <Superhero>() { new Superhero() { Name = "No Data Available", Publisher = "", Rating = -1 }, }; } } }
// GET: api/Superheroes public IEnumerable <SuperheroDto> GetSuperheroes() { IEnumerable <SuperheroDto> result = superheroRepository.GetAll(); return(result); }