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(TestGroupCreateTestViewModel 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.ID,
                        N_TEST_SYSID       = Model.SelectedTest,
                        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.SelectedTest }));
                }

                Model.Tests = (List <SelectListItem>)_testRepo.GetTestGroupsSelectListByTestID(Model.ID);

                return(View(Model));
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    ViewBag.Message = "Function: TestGroupController.Create_POST\n\nError: " + ex.Message;
                }
                else
                {
                    ViewBag.Message = "Function: TestGroupController.Create_POST\n\nError: " + (ex.Message + "\n\nInnerException: " + ex.InnerException.Message);
                };
                Session["ErrorMessage"] = ViewBag.Message;
                return(RedirectToAction("InternalServerError", "Error"));
            };
        }