public async Task <EducationalCycleEditViewModel> CreateEducationalCycle(EducationalCycle educationalCycle)
        {
            var cycle = new EducationalCycleEditViewModel()
            {
                CycleName     = educationalCycle.Name,
                NumberOfHours = educationalCycle.NumberOfHours,
                Semester      = educationalCycle.Semester,
                TypeOfClasses = educationalCycle.TypeOfClasses,
                CycleId       = educationalCycle.Id,
                Faculties     = await GetFaculties(),
                Disciplines   = await GetDisciplines(),
            };

            if (educationalCycle.Group != null)
            {
                cycle.SelectedGroup = educationalCycle.GroupId.ToString();
                if (educationalCycle.Group.Department != null)
                {
                    cycle.Groups = await GetGroups(educationalCycle.Group.DepartmentId);

                    cycle.SelectedDepartment = educationalCycle.Group.DepartmentId.ToString();
                    if (educationalCycle.Group.Department.FacultyId != null)
                    {
                        cycle.SelectedFaculty = educationalCycle.Group.Department.FacultyId.ToString();
                        cycle.Departments     = await GetDepartments(educationalCycle.Group.Department.FacultyId);
                    }
                }
            }
            if (educationalCycle.DisciplineId != null)
            {
                cycle.SelectedDiscipline = educationalCycle.DisciplineId.ToString();
            }
            return(cycle);
        }
        public async Task <EducationalCycleEditViewModel> CreateEducationalCycle()
        {
            var cycle = new EducationalCycleEditViewModel()
            {
                Faculties   = await GetFaculties(),
                Departments = GetDepartments(),
                Groups      = GetGroups(),
                Disciplines = await GetDisciplines()
            };

            return(cycle);
        }
        public async Task <bool> SaveEducationalCycle(EducationalCycleEditViewModel cycleToSave)
        {
            if (cycleToSave != null)
            {
                var educationalCycle = new EducationalCycle()
                {
                    Name          = cycleToSave.CycleName,
                    Semester      = cycleToSave.Semester,
                    NumberOfHours = cycleToSave.NumberOfHours,
                    GroupId       = Guid.Parse(cycleToSave.SelectedGroup),
                    DisciplineId  = Guid.Parse(cycleToSave.SelectedDiscipline),
                    TypeOfClasses = cycleToSave.TypeOfClasses
                };
                var response = await _requestSender.SendPostRequestAsync("https://localhost:44389/api/EducationalCycles/create", educationalCycle);

                return(true);
            }

            return(false);
        }
        public async Task <IActionResult> OnGetAsync(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var cycle = await _requestSender.GetContetFromRequestAsyncAs <EducationalCycle>(
                await _requestSender.SendGetRequestAsync("https://localhost:44389/api/EducationalCycles/one?id=" + id)
                );

            educationalCycleEditViewModel = await _dropDownService.CreateEducationalCycle(cycle);

            return(Page());

            if (educationalCycleEditViewModel == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public async Task <bool> UpdateEducationalCycle(EducationalCycleEditViewModel cycleToUpdate)
        {
            if (cycleToUpdate != null)
            {
                var educationalCycle = new EducationalCycle()
                {
                    Id            = cycleToUpdate.CycleId,
                    Name          = cycleToUpdate.CycleName,
                    Semester      = cycleToUpdate.Semester,
                    NumberOfHours = cycleToUpdate.NumberOfHours,
                    TypeOfClasses = cycleToUpdate.TypeOfClasses,
                    DisciplineId  = Guid.Parse(cycleToUpdate.SelectedDiscipline),
                    GroupId       = Guid.Parse(cycleToUpdate.SelectedGroup)
                };
                var response = await _requestSender.SendPostRequestAsync("https://localhost:44389/api/EducationalCycles/update", educationalCycle);

                return(true);
            }

            // Return false if customeredit == null or CustomerID is not a guid
            return(false);
        }
Пример #6
0
        public async Task <IActionResult> OnGet()
        {
            educationalCycleEditViewModel = await _dropDownService.CreateEducationalCycle();

            return(Page());
        }