public ActionResult Create(int ID, int?TestGroupID) { try { REF_TEST_TB test = _uow.Repository <REF_TEST_TB>().GetById(ID); TestCreateGroupViewModel model = new TestCreateGroupViewModel() { ID = ID, SelectedTestGroup = 0, TestDescription = test.SZ_DESCRIPTION, TestGroups = (List <SelectListItem>)_testRepo.GetTestGroupsSelectListByTestID(ID) }; return(View(model)); } catch (Exception ex) { if (ex.InnerException == null) { ViewBag.Message = "Function: TestController.Create_GET\n\nError: " + ex.Message; } else { ViewBag.Message = "Function: TestController.Create_GET\n\nError: " + (ex.Message + "\n\nInnerException: " + ex.InnerException.Message); }; Session["ErrorMessage"] = ViewBag.Message; return(RedirectToAction("InternalServerError", "Error")); }; }
public ActionResult Create(TestCreateGroupViewModel Model, bool IsTest = false) { try { if (ModelState.IsValid) { string modifiedBy = IsTest ? "Unit Test Case" : _modifiedBy; REF_TEST_X_TEST_GROUP_TB record = new REF_TEST_X_TEST_GROUP_TB() { B_INACTIVE = false, DT_ENTERED = DateTime.UtcNow, DT_MODIFIED = DateTime.UtcNow, N_TEST_GROUP_SYSID = Model.SelectedTestGroup, N_TEST_SYSID = Model.ID, SZ_ENTERED_BY = modifiedBy, SZ_MODIFIED_BY = _modifiedBy }; _uow.Repository <REF_TEST_X_TEST_GROUP_TB>().Add(record); _uow.SaveChanges(); return(RedirectToAction("Details", new { ID = Model.ID, TestGroupID = Model.SelectedTestGroup })); } Model.TestGroups = (List <SelectListItem>)_testRepo.GetTestGroupsSelectListByTestID(Model.ID); return(View(Model)); } catch (Exception ex) { if (ex.InnerException == null) { ViewBag.Message = "Function: TestController.Create_POST\n\nError: " + ex.Message; } else { ViewBag.Message = "Function: TestController.Create_POST\n\nError: " + (ex.Message + "\n\nInnerException: " + ex.InnerException.Message); }; Session["ErrorMessage"] = ViewBag.Message; return(RedirectToAction("InternalServerError", "Error")); }; }