public PresentationWebResourceTestDto GetTest(int testId) { try { PresentationAutomapperConfig.Configure(); WebResourceTest test = this.dataUnit.GetRepository <WebResourceTest>().GetById(testId); PresentationWebResourceTestDto presentationTestResults = new PresentationWebResourceTestDto(); presentationTestResults = Mapper.Map <WebResourceTest, PresentationWebResourceTestDto>(test); presentationTestResults.TotalTestsCount = presentationTestResults.Tests.Sum(res => res.TestsCount); presentationTestResults.TotalWrongTestsCount = presentationTestResults.Tests.Sum(res => res.WrongTestsCount); presentationTestResults.WrongUrls = presentationTestResults.Tests.Where(res => res.WrongTestsCount == res.TestsCount).Count(); presentationTestResults.SuccessfulUrls = presentationTestResults.Tests.Where(res => res.WrongTestsCount == 0).Count(); presentationTestResults.TotalUrls = presentationTestResults.Tests.Count(); return(presentationTestResults); } catch { throw; } }
public ActionResult LoadTestResults(int testId = 0) { PresentationWebResourceTestDto results = new PresentationWebResourceTestDto(); int recordsTotal; try { string start = this.Request.Form.GetValues("start").FirstOrDefault(); int skip = start != null?Convert.ToInt32(start) : 0; recordsTotal = this.testService.Count(testId); results = this.testService.GetTest(testId); results.Tests = results.Tests .Skip(skip) .Take(1) .ToList(); return(this.Json( new { recordsTotal = recordsTotal, data = results }, JsonRequestBehavior.AllowGet)); } catch { } return(this.Json( new { recordsTotal = 0, data = results }, JsonRequestBehavior.AllowGet)); }