public void GetStudentExamsSVM()
        {
            ErrorsSVM = "";

            Student     student     = new Student();
            Exam        exam        = new Exam();
            StudentExam studentExam = new StudentExam();

            if (CurrentStudentSVM != null)
            {
                student = CurrentStudentSVM;
                studentExam.StudentId = student.Id;

                StudentExamsListSVM = studentExam.StudentByExams(studentExam.StudentId);
                if (CurrentSubjectNameSVM != null)
                {
                    StudentExamsBySubjectListSVM = StudentExamsListSVM.FindAll(x => x.Exam.Subject.Name == CurrentSubjectNameSVM).ToList();
                    exams = true;
                }
                else
                {
                    StudentExamsBySubjectListSVM = StudentExamsListSVM;
                    exams = true;
                }

                if (StudentExamsBySubjectListSVM.Count == 0)
                {
                    ErrorsSVM = "El alumno no ha realizado exámenes de " + CurrentSubjectNameSVM;
                    exams     = false;
                }
            }
        }
Пример #2
0
        public void GetStudentExamsSEVM()
        {
            Student     student     = new Student();
            Exam        exam        = new Exam();
            StudentExam studentExam = new StudentExam();

            if (CurrentStudentSEVM != null)
            {
                student = CurrentStudentSEVM;
                exam    = CurrentExamSEVM;
                studentExam.StudentId = student.Id;

                StudentExamsListSEVM = studentExam.StudentByExams(studentExam.StudentId);
            }
        }
        public void DelStudentExamsSEVM()
        {
            StudentExam studentExamMVM = new StudentExam();

            if (CurrentStudentExamSEVM == null)
            {
                MessageBox.Show("Se tiene que seleccionar un examen del estudiante antes de eliminarla");
            }
            else
            {
                MessageBox.Show("El examen del estudiante se ha eliminado correctamente");

                studentExamMVM = CurrentStudentExamSEVM;
                studentExamMVM.Delete();

                StudentExamsListSEVM = studentExamMVM.StudentByExams(studentExamMVM.StudentId);
            }
        }
        public void EditStudentExamsSEVM()
        {
            if (CurrentStudentSEVM != null)
            {
                MarkStringToDoubleS();

                StudentExam stexam = new StudentExam();

                var vrstex = examToUpdate.Save();

                if (vrstex.IsSuccess)
                {
                    MessageBox.Show($"La nota del examen del estudiante se ha editado correctamente");
                    CurrentStudentExamSEVM = vrstex.Entity;
                    StudentExamsListSEVM   = stexam.StudentByExams(stexam.StudentId);
                }
                else
                {
                    MessageBox.Show($"La nota del examen del estudiante no se ha editado correctamente");
                }

                CurrentStudentSEVM = null;
                CurrentExamS       = null;
                DniS           = "";
                NameS          = "";
                TitleS         = "";
                SubjectNameS   = "";
                DateS          = default;
                MarkTextS      = "";
                HasCheatedSEVM = default;
                this.Id        = default;

                //GetStudentExamsSEVM();
            }
            else
            {
                MessageBox.Show("Se tiene que seleccionar un examen de un estudiante antes de editarlo");
            }
        }
        public void SaveStudentExamsSEVM()
        {
            MarkStringToDoubleS();

            StudentExam stexam  = new StudentExam();
            Student     student = new Student();
            Exam        exam    = new Exam();

            exam    = CurrentExamS;
            student = CurrentStudentSEVM;

            if (MarkSEVM != 0)
            {
                if (CurrentStudentExamSEVM != null)
                {
                    stexam = CurrentStudentExamSEVM;
                }

                stexam.Mark = MarkSEVM;

                stexam.HasCheated = HasCheatedSEVM;

                if (CurrentStudentSEVM != null)
                {
                    stexam.StudentId = student.Id;

                    if (CurrentExamS != null)
                    {
                        stexam.ExamId = exam.Id;
                    }
                    if (CurrentStudentSEVM != null || CurrentStudentExamSEVM != null)
                    {
                        GetStudentExamsSEVM();

                        MarkTextS = "";
                    }
                }
            }

            stexam.Mark = MarkSEVM;

            var vrstex = stexam.Save();

            if (vrstex.IsSuccess)
            {
                MessageBox.Show($"La nota del examen del estudiante se ha guardado correctamente");
                StudentExamsListSEVM = stexam.StudentByExams(stexam.StudentId);
            }
            else
            {
                MessageBox.Show($"La nota del examen del estudiante no se ha guardado correctamente");
            }

            CurrentStudentSEVM = null;
            CurrentExamS       = null;
            DniS           = "";
            NameS          = "";
            TitleS         = "";
            SubjectNameS   = "";
            DateS          = default;
            MarkTextS      = "";
            HasCheatedSEVM = default;
            this.Id        = default;

            // GetStudentExamsSEVM();
        }