示例#1
0
        /// <summary>
        /// inside this method we call the rest api and retrieve a data
        /// </summary>
        /// <returns></returns>
        protected async override Task OnInitializedAsync()
        {
            int.TryParse(Id, out int planId);

            if (planId != 0)
            {
                Plan = await PlanService.GetPlan(int.Parse(Id));

                AutumnSemester = Plan.AutumnSemester;
                SpringSemester = Plan.SpringSemester;

                Semesters = new List <SemesterDto> {
                    AutumnSemester, SpringSemester
                };

                SemesterId     = Semester.SemesterId.ToString();
                ModuleId       = Module.ModuleId.ToString();
                Lmr            = new LecturerModuleRunDto();
                SelectedPlanId = Plan.Id;
                ListLmr        = (await LecturerModuleRunService.GetLecturerModuleRuns()).ToList();
                foreach (var sem in Semesters)
                {
                    foreach (var mr in sem.ModuleRuns)
                    {
                        ModuleRuns.Add(mr);
                    }
                }
                await ShowLastYearPlan();
            }


            else
            {
                Plan     = new PlanDto {
                };
                Semester = new SemesterDto {
                };
                Module   = new ModuleDto {
                };
                ListLmr  = new List <LecturerModuleRunDto> {
                };
            }
            Plans          = (await PlanService.GetPlans()).ToList();
            ModuleRuns     = (await ModuleRunService.GetModuleRuns()).ToList();
            Modules        = (await ModuleService.GetModules()).ToList();
            Lecturers      = (await LecturerService.GetLecturers()).ToList();
            LecturerGroups = (await LecturerGroupService.GetLecturerGroups()).ToList();
        }
示例#2
0
        protected async Task HandleValidSubmit()
        {
            PlanDto result = null;

            if (Semester.SemesterId != 0)
            {
                await SemesterService.UpdateSemester(AutumnSemester);

                await SemesterService.UpdateSemester(SpringSemester);

                await LecturerModuleRunService.UpdateLecturerModuleRun(Lmr);

                await ModuleRunService.UpdateModuleRun(MR);
            }

            if (Plan.Id != 0)
            {
                await PlanService.UpdatePlan(Plan);
            }
            else
            {
                result = await PlanService.CreatePlan(Plan);
            }
        }