public async Task<ActionResult> Details(string titleUrl) { var data = Repo.GetSiteTestPage(titleUrl); if (data == null) return new HttpNotFoundResult(); var breadcrumbs = (SxVMBreadcrumb[])ViewBag.Breadcrumbs; if (breadcrumbs != null) { var bc = breadcrumbs.ToList(); bc.Add(new SxVMBreadcrumb { Title = data.Question.Test.Title }); ViewBag.Breadcrumbs = bc.ToArray(); } if (data.Question.Test.Type == SiteTest.SiteTestType.Guess) { var step = new VMSiteTestStepGuess(); step.QuestionId = data.QuestionId; step.IsCorrect = false; ViewBag.OldSteps = new VMSiteTestStepGuess[] { step }; } else if (data.Question.Test.Type == SiteTest.SiteTestType.Normal || data.Question.Test.Type == SiteTest.SiteTestType.NormalImage) { var step = new VMSiteTestStepNormal(); step.SubjectId = data.SubjectId; step.QuestionId = 0; step.LettersCount = getStepNormalLettersCount(data); ViewBag.OldSteps = new VMSiteTestStepNormal[] { step }; } var viewModel = Mapper.Map<SiteTestAnswer, VMSiteTestAnswer>(data); if (viewModel.Question != null && viewModel.Question.Test != null) viewModel.Question.Test.ViewsCount = await Repo.AddShow(viewModel.Question.Test.Id); return View(model: viewModel); }
public async Task <ActionResult> Details(string titleUrl) { var data = Repo.GetSiteTestPage(titleUrl); if (data == null) { return(new HttpNotFoundResult()); } if (data.Question.Test.Type == SiteTest.SiteTestType.Guess) { var step = new VMSiteTestStepGuess(); step.QuestionId = data.QuestionId; step.IsCorrect = false; ViewBag.OldSteps = new VMSiteTestStepGuess[] { step }; } else if (data.Question.Test.Type == SiteTest.SiteTestType.Normal || data.Question.Test.Type == SiteTest.SiteTestType.NormalImage) { var step = new VMSiteTestStepNormal { SubjectId = data.SubjectId, QuestionId = 0, LettersCount = GetStepNormalLettersCount(data) }; ViewBag.OldSteps = new[] { step }; } var viewModel = Mapper.Map <SiteTestAnswer, VMSiteTestAnswer>(data); if (viewModel.Question?.Test != null) { viewModel.Question.Test.ViewsCount = await Repo.AddShow(viewModel.Question.Test.Id); } return(View(model: viewModel)); }