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); }
public List <SuperHero> GetAllHeroes() { Task <List <SuperHero> > getHerosTask = repo.GetAllHeroesAsync(); return(getHerosTask.Result); }
public async Task <IActionResult> GetAllHeroes() { var superHeroes = await _repo.GetAllHeroesAsync(); return(View(superHeroes)); }
public List <SuperHero> GetAllHeroes() { List <SuperHero> getHerosTask = repo.GetAllHeroesAsync(); return(getHerosTask); }