public ActionResult Edit(TestW test) { if (ModelState.IsValid) { var response = _rep.Edit(test); if (response.IsSuccess) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("ErrorExists", response.Error.ErrorText); } } ViewBag.TestCategoryId = new SelectList(_rep.GetCategories(), "Id", "Name", test.TestCategoryId); ViewBag.AcredetationLevelId = new SelectList(_rep.GetAcredetationLevels(), "Id", "Level", test.AcredetationLevelId); ViewBag.TypeId = new SelectList(_rep.GetTestTypes(), "Id", "Type", test.TypeId); return(View(test)); }