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());
 }
Exemple #2
0
 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
                 },
             };
         }
     }
 }
Exemple #3
0
        // GET: api/Superheroes
        public IEnumerable <SuperheroDto> GetSuperheroes()
        {
            IEnumerable <SuperheroDto> result = superheroRepository.GetAll();

            return(result);
        }