예제 #1
0
        public void AddHero(SuperHero newHero)
        {
            //Making sure aliases are unique before adding
            Task <List <SuperHero> > getHerosTask = repo.GetAllHeroesAsync();

            foreach (var hero in getHerosTask.Result)
            {
                if (newHero.Alias.Equals(hero.Alias))
                {
                    throw new Exception("Hero aliases should be unique. That superhero already exists in our db");
                }
            }
            repo.AddAHeroAsync(newHero);
        }
예제 #2
0
        public List <SuperHero> GetAllHeroes()
        {
            Task <List <SuperHero> > getHerosTask = repo.GetAllHeroesAsync();

            return(getHerosTask.Result);
        }
예제 #3
0
        public async Task <IActionResult> GetAllHeroes()
        {
            var superHeroes = await _repo.GetAllHeroesAsync();

            return(View(superHeroes));
        }
        public List <SuperHero> GetAllHeroes()
        {
            List <SuperHero> getHerosTask = repo.GetAllHeroesAsync();

            return(getHerosTask);
        }