public ActionResult AddHult(int id, Route route) { try { IEnumerable <Hult> hults = routeDAO.GetHultWhithout(id); ViewBag.AllHult = new SelectList(hults, "id", "hultName"); List <Hult> hultList = routeDAO.GetHultById(id); int count = hultList.Count(); if (count > 0) { Hult hult = hultList[hultList.Count - 1]; hultList.RemoveAt(count - 1); ViewBag.IDList = hultList; ViewBag.LustHult = hult.HultName; } if (routeDAO.AddHult(id, route.HultId)) { return(RedirectToAction("Index")); } else { return(View("AddHult")); } } catch { return(View("AddHult")); } }