public ActionResult ThemeDetails(int themeId) { var testRepo = new TestRepository(); var theme = testRepo.GetThemeInfo(themeId); if (theme == null) { RedirectToAction("Themes"); } Mapper.Initialize(cfg => cfg.CreateMap <DataAccessLayer.Models.QuestionModel, QuestionViewModel>()); var questions = testRepo.GetThemeQuestions(themeId) .Select(x => Mapper.Map <DataAccessLayer.Models.QuestionModel, QuestionViewModel>(x)) .ToList(); var themeDetails = new ThemeDetailsViewModel { ThemeID = theme.ThemeID, ThemeName = theme.ThemeName, QuestionsCount = theme.QuestionsCount, Questions = questions }; return(View(themeDetails)); }
public async Task <IActionResult> Details(string themeId, string page) { int id = int.Parse(themeId); int pageNum = int.Parse(page); var theme = new ThemeDetailsViewModel { ThemeDetails = await this.themes.ById(id), Articles = await this.articles.ByThemeIdAsync(id, pageNum), TotalArticles = await this.articles.TotalByThemeIdAsync(id), CurrentPage = pageNum }; return(View(theme)); }