Exemplo n.º 1
0
        public void SaveStudentExamsSEVM()
        {
            MarkStringToDouble();
            StudentExam studentExamsSEVM = new StudentExam();

            if (MarkSEVM != 0)
            {
                Exam    exam    = new Exam();
                Student student = new Student();
                ErrorsList = new List <ErrorMessage>();


                exam    = CurrentExamSEVM;
                student = CurrentStudentSEVM;
                if (CurrentStudentExamSEVM != null)
                {
                    studentExamsSEVM = CurrentStudentExamSEVM;
                }

                studentExamsSEVM.Mark       = MarkSEVM;
                studentExamsSEVM.HasCheated = HasCheatedSEVM;
                if (CurrentStudentSEVM != null)
                {
                    studentExamsSEVM.StudentId = student.Id;

                    if (CurrentExamSEVM != null)
                    {
                        studentExamsSEVM.ExamId = exam.Id;
                    }
                }

                studentExamsSEVM.Save();

                ErrorsList = studentExamsSEVM.CurrentValidation.Errors.Select(x => new ErrorMessage()
                {
                    Message = x
                }).ToList();                                                                                                      //Nou

                if (CurrentStudentSEVM != null || CurrentStudentExamSEVM != null)
                {
                    GetStudentExamsSEVM();
                    MarkTextSEVM = "";
                }
            }


            CurrentStudentSEVM     = null;
            _currentExamSEVM       = null;
            CurrentStudentExamSEVM = null;
            DniSEVM         = "";
            NameSEVM        = "";
            TitleSEVM       = "";
            SubjectNameSEVM = "";
            DateSEVM        = default;
            MarkSEVM        = 0;
            HasCheatedSEVM  = false;

            isEdit = false;
        }
        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();
        }