public async Task <WorkManagementCycleEditViewModel> CreateWorkMangementCycle(WorkManagementCycle workManagementCycle)
        {
            var cycle = new WorkManagementCycleEditViewModel()
            {
                CycleName     = workManagementCycle.Name,
                NumberOfHours = workManagementCycle.NumberOfHours,
                Semester      = workManagementCycle.Semester,
                CycleId       = workManagementCycle.Id,
                Faculties     = await GetFaculties()
            };

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

                    cycle.SelectedDepartment = workManagementCycle.Group.DepartmentId.ToString();
                    if (workManagementCycle.Group.Department.FacultyId != null)
                    {
                        cycle.SelectedFaculty = workManagementCycle.Group.Department.FacultyId.ToString();
                        cycle.Departments     = await GetDepartments(workManagementCycle.Group.Department.FacultyId);
                    }
                }
            }
            return(cycle);
        }
        public async Task <WorkManagementCycleEditViewModel> CreateWorkMangementCycle()
        {
            var cycle = new WorkManagementCycleEditViewModel()
            {
                Faculties   = await GetFaculties(),
                Departments = GetDepartments(),
                Groups      = GetGroups()
            };

            return(cycle);
        }
        public async Task <bool> SaveWorkManagementCycle(WorkManagementCycleEditViewModel cycleToSave)
        {
            if (cycleToSave != null)
            {
                var workManagementCycle = new WorkManagementCycle()
                {
                    Name          = cycleToSave.CycleName,
                    Semester      = cycleToSave.Semester,
                    NumberOfHours = cycleToSave.NumberOfHours,
                    GroupId       = Guid.Parse(cycleToSave.SelectedGroup)
                };
                var response = await _requestSender.SendPostRequestAsync("https://localhost:44389/api/WorkManagementCycles/create", workManagementCycle);

                return(true);
            }

            // Return false if customeredit == null or CustomerID is not a guid
            return(false);
        }
        public async Task <IActionResult> OnGetAsync(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var cycle = await _requestSender.GetContetFromRequestAsyncAs <WorkManagementCycle>(
                await _requestSender.SendGetRequestAsync("https://localhost:44389/api/WorkManagementCycles/one?id=" + id)
                );

            WorkManagementCycleEditViewModel = await _dropDownService.CreateWorkMangementCycle(cycle);

            return(Page());

            if (WorkManagementCycleEditViewModel == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Beispiel #5
0
        public async Task <IActionResult> OnGet()
        {
            WorkManagementCycleEditViewModel = await _dropDownService.CreateWorkMangementCycle();

            return(Page());
        }