Exemplo n.º 1
0
        public bool AddStudent(STUDENT student, string schoolYearId, string ClassId)
        {
            bool flag = false;

            try
            {
                if (student.MSHOCSINH == null)
                {
                    student.MSHOCSINH = CreateMSHS();
                    _QuanLyHocSinhEntities.STUDENT.Add(student);
                }
                else
                {
                    var findStudent = _QuanLyHocSinhEntities.STUDENT.Where(s => s.MSHOCSINH == student.MSHOCSINH).Take(1).ToList();
                    if (findStudent.Count == 0)
                    {
                        student.MSHOCSINH = CreateMSHS();
                        _QuanLyHocSinhEntities.STUDENT.Add(student);
                        flag = true;
                    }
                    else
                    {
                        student = findStudent[0];//ton tai cu
                    }
                }
                if (flag == false)//ko ton tai => tao account
                {
                    AccountController accountController = new AccountController();
                    flag = accountController.CreateAccount(student.MSHOCSINH);
                }
                if (flag)
                {
                    flag = AddStudentClass(student, schoolYearId, ClassId);
                }

                if (flag)
                {
                    ScoresController scoresController = new ScoresController();
                    flag = scoresController.CreateListCores(schoolYearId, student.MSHOCSINH);
                }
                if (flag)
                {
                    LearningOutComeController learningOutComeController = new LearningOutComeController();
                    learningOutComeController.createListLearningOutCome(student.MSHOCSINH, schoolYearId);
                }
                _QuanLyHocSinhEntities.SaveChanges();
                flag = true;
            }
            catch (Exception)
            {
                flag = false;
            }
            return(flag);
        }
Exemplo n.º 2
0
        public bool RemoveStudent(string MSHS, string schoolYearId, string ClassId)
        {
            ScoresController          scoresController          = new ScoresController();
            LearningOutComeController learningOutComeController = new LearningOutComeController();
            AccountController         accountController         = new AccountController();

            scoresController.RemoveListTestScore(MSHS, schoolYearId);
            learningOutComeController.removeListLearningOutCome(MSHS, schoolYearId);
            RemoveStudentClass(MSHS, schoolYearId, ClassId);
            accountController.RemoveAccount(MSHS);
            _QuanLyHocSinhEntities.SaveChanges();
            return(true);
        }