コード例 #1
0
        private async void RemoveItem_Click(object sender, RoutedEventArgs e)
        {
            if (CoursesLV.SelectedItem != null)
            {
                if (CoursesTab.IsSelected)
                {
                    await NetworkTools.PostAsync("/Data/Course/RemoveCourse", $"ID={((Course)CoursesLV.SelectedItem).ID}");
                }
                else if (MarksTab.IsSelected)
                {
                    await NetworkTools.PostAsync("/Data/Mark/RemoveMark", $"ID={((Mark)MarksLV.SelectedItem).ID}");
                }
                else if (StatementsTab.IsSelected)
                {
                    await NetworkTools.PostAsync("/Data/Statement/RemoveStatement", $"ID={((Statement)StatementsLV.SelectedItem).ID}");
                }

                UpdateData();
            }
        }
コード例 #2
0
        async void UpdateData(bool resetSettingsContainers = true)
        {
            var accounts = (await NetworkTools.GetAsync <Account>("/Data/Account/GetAccounts")) /*.Where(c => c.AccessLevel == Account.AL_USER)*/;
            var courses  = await NetworkTools.GetAsync <Course>("/Data/Course/GetCourses");

            var marks = await NetworkTools.GetAsync <Mark>("/Data/Mark/GetMarks");

            marks.ForEach(mark =>
            {
                mark.Student = accounts.Find(account => account.ID == mark.AccountID);
                mark.Course  = courses.Find(course => course.ID == mark.CourseID);
            });


            CoursesLV.ItemsSource    = CoursesCB.ItemsSource = courses;
            MarksLV.ItemsSource      = marks;
            StatementsLV.ItemsSource = await NetworkTools.GetAsync <Mark>("/Data/Statement/GetStatements");

            StudentsCB.ItemsSource = accounts;

            CourseSettingContainer.Visibility = Visibility.Collapsed;
            MarkSettingContainer.Visibility   = Visibility.Collapsed;
        }
コード例 #3
0
        private async void SubmitButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Account.Password      = PasswordTB.Password;
                var(StatusCode, Body) = await NetworkTools.PostAsync <AuthToken>(_signUpMode? "/Auth/SignUp" : "/Auth/SignIn", Account);

                if (StatusCode == HttpStatusCode.OK)
                {
                    DialogResult = true;
                    //TODO:Implement WhoAmI functionality
                    App.Token = (AuthToken)Body;
                }
                else
                {
                    MessageBox.Show("Неправильно указана электронная почта или пароль!");
                }
            }
            catch (HttpRequestException exc)
            {
                MessageBox.Show(exc.ToString());
            }
        }
コード例 #4
0
        private async void SaveMarkButton_Click(object sender, RoutedEventArgs e)
        {
            await NetworkTools.PostAsync("/Data/Mark/SetMark", MarkSettingContainer.DataContext);

            UpdateData();
        }
コード例 #5
0
        private async void SaveCourseButton_Click(object sender, RoutedEventArgs e)
        {
            await NetworkTools.PostAsync("/Data/Course/SetCourse", CourseSettingContainer.DataContext);

            UpdateData();
        }