public ActionResult Index(string id = "0") { if (!(Convert.ToInt32(id) > 0)) { RedirectToAction("Index/"); } ChampionViewModel selectedChampion = new ChampionViewModel(); ViewBag.ChampionSelectList = CreateChampionSelectList(); selectedChampion = GetChampionByID(Convert.ToInt32(id)); ViewBag.SelectedChampion = selectedChampion.ID; return View(selectedChampion); }
public ChampionViewModel GetChampionByID(int id) { Champion champion = new Champion(); ChampionViewModel championVM = new ChampionViewModel(); ChampionBLL cBLL = new ChampionBLL(); champion = cBLL.GetChampionByID(id); championVM = AutoMapper.Mapper.Map<Champion, ChampionViewModel>(champion); return championVM; }