Exemplo n.º 1
0
        // Run and validate, get nesscessary data
        private async Task <string> PreLaunch(Guid?exId, Guid?skillCatId, Guid?skillPartId, Guid?id)
        {
            if (exId == null || exId == Guid.Empty)
            {
                ToastError(L["Please select correct exam category"]);
                return($"/manager/exam-categories");
            }

            if (skillCatId == null || skillCatId == Guid.Empty)
            {
                ToastError(L["Please select correct skill category"]);
                return($"/manager/exam-categories/{exId}/skill-categories");
            }

            if (skillPartId == null || skillPartId == Guid.Empty)
            {
                ToastError(L["Please select correct skill part"]);
                return($"/manager/exam-categories/{exId}/skill-categories/{skillCatId}/skill-parts");
            }

            // Lấy loại kỳ thi
            var examCat = await _ExamCategoryService.GetSimpify(exId.Value);

            if (!examCat.Success)
            {
                ToastError(examCat.Message);
                return($"/manager/exam-categories");
            }
            CurrentExamCategory = examCat.Data;

            // Lấy mục kỹ năng
            var skCat = _SkillCategoryService.GetSimpify(skillCatId.Value);

            if (!skCat.Success)
            {
                ToastError(skCat.Message);
                return($"/manager/exam-categories/{exId}/skill-categories");
            }
            CurrentSkillCategory = skCat.Data;

            // Lấy phần của mục kỹ năng
            var skPart = _SkillPartService.GetSimpify(skillPartId.Value);

            if (!skPart.Success)
            {
                ToastError(skPart.Message);
                return($"/manager/exam-categories/{exId}/skill-categories/{skillCatId}/skill-parts");
            }
            CurrentSkillPart = skPart.Data;

            if (CurrentSkillPart.MasterContentType == Common.MasterContentTypes.Grammar)
            {
                var res = await _GrammarService.GetAllSimpifyAsync();

                if (!res.Success || res.Data == null)
                {
                    ToastError(res.Message);
                    return("");
                }
                Grammars = res.Data;
            }

            return(null);
        }