Beispiel #1
0
        public ActionResult DeleteTestCase(IList <TestCase> rows)
        {
            var testCaseRepo = new TestCaseRepository();

            foreach (var row in rows)
            {
                var testCase = testCaseRepo.GetById(row.Id);

                if (testCase.Evidences != null && testCase.Evidences.Count > 0)
                {
                    var evidenceRepo = new EvidenceRepository();
                    foreach (var evidence in testCase.Evidences)
                    {
                        System.IO.File.Delete(Server.MapPath("~/Uploads/" + evidence.Name + evidence.Extension));
                        evidenceRepo.Delete(evidence);
                    }
                }

                if (testCase.Reviews != null && testCase.Reviews.Count > 0)
                {
                    var reviewsRepo = new ReviewRepository();
                    foreach (var review in testCase.Reviews)
                    {
                        reviewsRepo.Delete(review);
                    }
                }

                testCaseRepo.Delete(testCase);
            }

            TempData["success"] = "Test case/s was deleted!";

            return(View("CompanyTests"));
        }
        public ActionResult DeleteTestGroupAll(IList <TestGroup> rows)
        {
            IList <Guid> testCasesId = new List <Guid>();

            foreach (var row in rows)
            {
                var       testGroupRepo = new TestGroupRepository();
                TestGroup testGroup     = testGroupRepo.GetById(row.Id);
                foreach (var testCase in testGroup.TestCases)
                {
                    testCase.IsInGroup = false;
                    testCasesId.Add(testCase.Id);
                }

                testGroupRepo.Update(testGroup);
                testGroupRepo.Delete(testGroup);
            }

            TestCaseRepository testCaseRepo = new TestCaseRepository();

            foreach (var id in testCasesId)
            {
                TestCase testCase = testCaseRepo.GetById(id);

                if (testCase.Evidences != null && testCase.Evidences.Count > 0)
                {
                    var evidenceRepo = new EvidenceRepository();
                    foreach (var evidence in testCase.Evidences)
                    {
                        System.IO.File.Delete(Server.MapPath("~/Uploads/" + evidence.Name + evidence.Extension));
                        evidenceRepo.Delete(evidence);
                    }
                }

                if (testCase.Reviews != null && testCase.Reviews.Count > 0)
                {
                    var reviewsRepo = new ReviewRepository();
                    foreach (var review in testCase.Reviews)
                    {
                        reviewsRepo.Delete(review);
                    }
                }

                testCaseRepo.Delete(testCase);
            }

            TempData["success"] = "Test group/s and tests was deleted!";

            return(View("CompanyTestGroups"));
        }