示例#1
0
        private void btn_login_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(tbx_inloggEmail.Text) ||
                string.IsNullOrEmpty(tbx_login.Password))
            {
                MessageBox.Show("All fields must be filled");
            }
            else
            {
                User user = Repo.CheckEmail(tbx_inloggEmail.Text);

                if (user != null)
                {
                    if (user.Password == tbx_login.Password &&
                        user.IsAdmin == false)
                    {
                        SwitchScreen();
                        LoggedInUserId = user.Id;
                        GetQuizForUser(LoggedInUserId);
                        lv_QuizList.ItemsSource = Quizzes;
                        UtilityTestVerktyg.GetUserGrade(LoggedInUserId);
                        lv_Result.ItemsSource = UtilityTestVerktyg.UserGrades;
                    }
                    else
                    {
                        MessageBox.Show("Wrong password");
                    }
                }
                else
                {
                    MessageBox.Show("User doesn't excist");
                }
            }
        }
示例#2
0
        public MainWindow()
        {
            InitializeComponent();

            grid_loggedin.Visibility = Visibility.Hidden;

            DataContext = this;
            listViewQuestion.ItemsSource = UtilityTestVerktyg.QuizQuestions;
            UtilityTestVerktyg.GetUsers();                      // Ropa på utility för att hämta users till utitlity.Users
            lv_userList.ItemsSource = UtilityTestVerktyg.Users; // binding för Utility.Users
            UtilityTestVerktyg.GetQuizForAdmin();
            lv_QuizList.ItemsSource = UtilityTestVerktyg.AdminQuizzes;


            UpdateStatistics();
            UpdateCbxForStat();
        }
示例#3
0
        private void QuizWindowClosed(object sender, EventArgs e)
        {
            if (!Repo.DoesGradeExcist(SelectedQuizId, LoggedInUserId))
            {
                Quizzes.Remove(UtilityTestVerktyg.SelectedQuiz);

                var userGrade = new Grade
                {
                    CompletionDate = DateTime.Now,
                    QuizId         = SelectedQuizId,
                    UserId         = LoggedInUserId,
                    UserScore      = CurrentPoints.Sum(),
                    UserGrade      = (CurrentPoints.Sum() > QuizLength / 2) ? "G" : "IG"
                };
                Repo.SaveUserQuizScore(userGrade);
            }
            UtilityTestVerktyg.GetUserGrade(LoggedInUserId);
            lv_Result.ItemsSource           = UtilityTestVerktyg.UserGrades;
            UtilityTestVerktyg.SelectedQuiz = null;
        }