コード例 #1
0
        public void LoadGrade(string studentName, GradeViewModel grade)
        {
            _studentName = studentName;
            _grade       = grade;

            IsEnabled = (RightsEnum.Success == UserViewModel.CurrentUser.CanEdit(_grade));

            if (CourseViewModel.HasSpecialGrade(grade.Subject))
            {
                entSpecialGrade.Visibility = System.Windows.Visibility.Visible;
                staSpecialGrade.Visibility = System.Windows.Visibility.Visible;
            }

            Maintenance.LetterGrades.Keys.ToList().ForEach(g => cmbLetterGrade.Items.Add(g));

            Maintenance.Comments.ToList().ForEach(g => cmbComment.Items.Add(g));
            cmbComment.SelectedIndex = 0;

            staStudent.Content   = studentName;
            staCourse.Content    = _grade.Subject + " for " + _grade.MarkingPeriod + " " + _grade.Group + " with " + _grade.Teacher;
            cmbLetterGrade.Text  = _grade.LetterGrade;
            entSpecialGrade.Text = _grade.SpecialGrade;

            var comment = _grade.Comment;

            foreach (var c in Maintenance.Comments)
            {
                var formattedComment = Maintenance.FormatCommentFromList(c);
                if (string.IsNullOrWhiteSpace(formattedComment))
                {
                    continue;
                }
                if (comment.StartsWith(formattedComment))
                {
                    cmbComment.Text = c;
                    comment         = comment.Substring(formattedComment.Length).Trim();
                    break;
                }
            }
            entComment.Text = comment;
        }