public async Task <List <Ex> > GetDataCollection() { // Lấy danh sách kỳ thi (await _ExamCategoryServices.GetBase()).Data .ForEach(x => { var ex = new Ex { Exam = x, Scs = new List <Sc>() }; _SkillCategoryServices.GetBase(x.Id).Data .ForEach(y => { var sc = new Sc { Cat = y, Parts = _SkillPartServices.GetBase(y.Id).Data }; ex.Scs.Add(sc); }); Exams.Add(ex); }); return(Exams); }
public async Task <IActionResult> OnGetAsync(Guid?exId, Guid?skillCatId) { if (exId == null || exId == Guid.Empty) { ToastError(L["Please select correct exam category"]); return(Redirect($"/manager/exam-categories")); } else if (skillCatId == null || skillCatId == Guid.Empty) { ToastError(L["Please select correct skill category"]); return(Redirect($"/manager/exam-categories/{exId}/skill-categories")); } else { var examCat = await _ExamCategoryService.GetSimpify(exId.Value); if (examCat.Success) { CurrentExamCategory = examCat.Data; var skCat = _SkillCategoryService.GetSimpify(skillCatId.Value); if (skCat.Success) { CurrentSkillCategory = skCat.Data; var res = _SkillPartService.GetBase(skillCatId.Value); if (res.Success) { SkillParts = res.Data; return(Page()); } else { ToastError(res.Message); } } else { ToastError(skCat.Message); } return(Redirect($"/manager/exam-categories/{exId}/skill-categories")); } ToastError(examCat.Message); return(Redirect($"/manager/exam-categories")); } }
public async Task <IActionResult> Detail(HelperTipsTypes type, Guid id, [FromQuery(Name = "ex")] string ex, [FromQuery(Name = "sc")] string sc, [FromQuery(Name = "instructor")] Guid?instructor) { // Mã của dối tượng hiện tại ViewBag.Id = id; // Cho biết có hiển thị nút cập nhật dữ liệu hay không ViewBag.ShowManagerButton = type == HelperTipsTypes.SkillPart; var renderType = -1; if (type == HelperTipsTypes.Exam) { var exam = (await _ExamCategoryServices.GetAsync(id)).Data; ViewBag.ModalName = $"{exam.Name} Exam's tips"; ViewBag.ModalContent = exam.Tips; renderType = (int)RenderExamTypes.Synthetic; } else if (type == HelperTipsTypes.SkillCategory) { var sCat = (await _SkillCategoryServices.GetAsync(id)).Data; var skPs = _SkillPartServices.GetBase(sCat.Id).Data; if (skPs.Count <= 1) { ViewBag.ShowManagerButton = true; ViewBag.Id = skPs.FirstOrDefault()?.Id ?? Guid.Empty; } ViewBag.ModalName = $"{sCat.Name} of {ex} Exam's tips"; ViewBag.ModalContent = sCat.Tips; renderType = (int)RenderExamTypes.SkillCategory; } else if (type == HelperTipsTypes.SkillPart) { var sPart = (await _SkillPartServices.GetAsync(id)).Data; ViewBag.ModalName = $"{sc} {sPart.Name} of {ex} Exam's tips"; ViewBag.ModalContent = sPart.Tips; renderType = (int)RenderExamTypes.SkillPart; } ViewBag.StartExamUrl = $"/exams/{renderType}/exam/{id}?instructor={instructor}"; return(PartialView("~/Pages/Exams/Partials/Detail.cshtml")); }