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();
            }
        }
        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;
        }
Exemple #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());
            }
        }
        private async void SaveMarkButton_Click(object sender, RoutedEventArgs e)
        {
            await NetworkTools.PostAsync("/Data/Mark/SetMark", MarkSettingContainer.DataContext);

            UpdateData();
        }
        private async void SaveCourseButton_Click(object sender, RoutedEventArgs e)
        {
            await NetworkTools.PostAsync("/Data/Course/SetCourse", CourseSettingContainer.DataContext);

            UpdateData();
        }