protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     this.learningUnit = e.Parameter as LearningUnit;
     this.modules.Clear();
     this.learningUnit.modules.ForEach(modules.Add);
     this.learningUnitName = learningUnit.name;
 }
예제 #2
0
        public async Task <LearningUnit> getLearningUnitAsync(string learningUnitId)
        {
            HttpResponseMessage response =
                await this.http.GetAsync(url + $"/api/learningunit/{learningUnitId}");

            if (response.IsSuccessStatusCode)
            {
                LearningUnit learningUnit = await response.Content.ReadAsAsync <LearningUnit>();

                return(learningUnit);
            }

            return(null);
        }
예제 #3
0
        public async Task <LearningUnit> updateUnit(LearningUnit unit)
        {
            HttpResponseMessage response =
                await this.http.PutAsJsonAsync(url + $"/api/learningunit/{unit.id}", unit);

            if (response.IsSuccessStatusCode)
            {
                LearningUnit learningUnit = await response.Content.ReadAsAsync <LearningUnit>();

                this.getLearningUnitsAsync();
                return(learningUnit);
            }

            return(null);
        }
        private async void handleClickAddGrade(object sender, RoutedEventArgs e)
        {
            Module module        = (Module)((Button)sender).DataContext;
            var    gradeDialog   = new GradeDialog(new Grade(), module.id, GradeDialog.GradeDialogMode.CREATE);
            var    buttonClicked = await gradeDialog.ShowAsync();

            module.grades.Add(gradeDialog.result);

            if (buttonClicked == ContentDialogResult.Primary)
            {
                this.learningUnit = await PsApi.getInstance().getLearningUnitAsync(this.learningUnit.id);

                this.modules.Clear();
                this.learningUnit.modules.ForEach(modules.Add);
            }
        }
예제 #5
0
        public async Task addLearningUnitAsync(LearningUnit learningUnit)
        {
            HttpResponseMessage response = await this.http.PostAsJsonAsync(url + "/api/learningunit", learningUnit);

            if (response.IsSuccessStatusCode)
            {
                LearningUnit unit = await response.Content.ReadAsAsync <LearningUnit>();

                this._learningUnits.Add(unit);
            }
            else
            {
                ContentDialog dialog = new ContentDialog()
                {
                    Title = response.StatusCode
                };
                await dialog.ShowAsync();
            }
        }
예제 #6
0
 private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
 {
     this.result = await PsApi.getInstance().updateUnit(this.result);
 }
예제 #7
0
 public UnitDialog(LearningUnit unit)
 {
     this.InitializeComponent();
     this.result = unit;
 }
예제 #8
0
 private void handleChangeSelectedUnit(Microsoft.UI.Xaml.Controls.NavigationView sender,
                                       Microsoft.UI.Xaml.Controls.NavigationViewSelectionChangedEventArgs args)
 {
     this.selectedUnit = args.SelectedItem as LearningUnit;
     this.contentFrame.Navigate(typeof(LearningUnitView), this.selectedUnit);
 }