public IActionResult AllePokemon() { if (HttpContext.Session.GetInt32("AccountID") == null) { return(RedirectToAction("Login", "Account")); } AllePokemonConvert pvc = new AllePokemonConvert(); AllePokemonViewModel apvm = pvc.PokemonToView(pokemonRepo.GetAll()); return(View(apvm)); }
public AllePokemonViewModel PokemonToView(List <Pokemon> pList) { AllePokemonViewModel apvm = new AllePokemonViewModel(); List <AllePokemonViewModel> temp = new List <AllePokemonViewModel>(); foreach (Pokemon p in pList) { AllePokemonViewModel apvmTemp = new AllePokemonViewModel(); apvmTemp.Id = p.Id; apvmTemp.Naam = p.Naam; apvmTemp.Type = SoortViewModelConvert.SoortToViewModel(p.Type); apvmTemp.Image = System.Convert.ToBase64String(p.Uiterlijk); apvmTemp.Aanvallen = AanvalViewModelConvert.AanvalListToViewModelList(p.Aanvallen); temp.Add(apvmTemp); } apvm.AllePokemon = temp; return(apvm); }
public IActionResult Delete(AllePokemonViewModel apvm) { pokemonRepo.Delete(apvm.Id); return(RedirectToAction("AllePokemon")); }