public ActionResult Create(TestCaseVM testCaseVM)
        {
            var testCase = Mapper.Map<TestCaseVM, TestCase>(testCaseVM);
            db.TestCases.Add(testCase);
            db.SaveChanges();

            for (int i = 0; i < testCaseVM.action.Length; i++)
            {
                var step = new Step
                {
                    Action = testCaseVM.action[i],
                    Result = testCaseVM.result[i],
                    TestCaseId = testCase.TestCaseID
                };

                db.Steps.Add(step);
                db.SaveChanges();
            }

            return RedirectToAction("Index", "TestCasesPerTestSuite");
        }
        public ActionResult Edit(TestCaseVM testCaseVM)
        {
            var testCase = db.TestCases.Find(testCaseVM.TestCaseID);
            if (testCase == null) return HttpNotFound();
            db.Entry(testCase).CurrentValues.SetValues(testCaseVM);
            DeleteRemovedSteps(testCase, testCaseVM.stepsID);

            // For each id on stepsID >> id = 0: new step, id already on Steps: update step.
            for (int i = 0; i < testCaseVM.stepsID.Length; i++)
            {
                if (testCaseVM.stepsID[i] == "0")
                {
                    var step = new Step
                    {
                        Action = testCaseVM.action[i],
                        Result = testCaseVM.result[i],
                        TestCaseId = testCase.TestCaseID
                    };

                    db.Steps.Add(step);
                    db.SaveChanges();
                }
                else if (TestCaseContainsStep(testCase, Convert.ToInt32(testCaseVM.stepsID[i])))
                {
                    var step = db.Steps.Find(Convert.ToInt32(testCaseVM.stepsID[i]));
                    step.Action = testCaseVM.action[i];
                    step.Result = testCaseVM.result[i];
                    step.TestCaseId = testCase.TestCaseID;
                    db.Entry(step).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }

            db.Entry(testCase).State = EntityState.Modified;
            db.SaveChanges();

            return RedirectToAction("Index", new { id = testCase.TestCaseID });
        }