Esempio n. 1
0
        public async Task <IActionResult> OnGetAsync(
            Guid?exId,
            Guid?skillCatId,
            Guid?skillPartId)
        {
            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 if (skillPartId == null || skillPartId == Guid.Empty)
            {
                ToastError(L["Please select correct skill part"]);
                return(Redirect($"/manager/exam-categories/{exId}/skill-categories/{skillCatId}/skill-parts"));
            }
            else
            {
                // Lấy exam category
                var examCat = await _ExamCategoryService.GetSimpify(exId.Value);

                if (examCat.Success)
                {
                    CurrentExamCategory = examCat.Data;
                    // Lấy skill category
                    var skCat = _SkillCategoryService.GetSimpify(skillCatId.Value);
                    if (skCat.Success)
                    {
                        CurrentSkillCategory = skCat.Data;
                        // Lấy skill part
                        var skPart = _SkillPartService.GetSimpify(skillPartId.Value);
                        if (skPart.Success)
                        {
                            CurrentSkillPart = skPart.Data;
                            return(Page());
                        }
                        else
                        {
                            ToastError(skPart.Message);
                        }
                    }
                    else
                    {
                        ToastError(skCat.Message);
                    }
                    return(Redirect($"/manager/exam-categories/{exId}/skill-categories"));
                }
                ToastError(examCat.Message);
                return(Redirect($"/manager/exam-categories"));
            }
        }
        public async Task <string> PreLaunch(Guid?exId, Guid?skillCatId, 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");
            }

            // 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;

            return(null);
        }
Esempio n. 3
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);
        }