public Grade UpdateGrade(Grade grade)
        {
            return(ExecuteFaultHandledOperation(() =>
            {
                var groupNames = new List <string>()
                {
                    BudgetModuleDefinition.GROUP_ADMINISTRATOR, BudgetModuleDefinition.GROUP_BUSINESS
                };
                AllowAccessToOperation(BudgetModuleDefinition.SOLUTION_NAME, groupNames);

                IGradeRepository gradeRepository = _DataRepositoryFactory.GetDataRepository <IGradeRepository>();

                Grade updatedEntity = null;

                if (grade.GradeId == 0)
                {
                    updatedEntity = gradeRepository.Add(grade);
                }
                else
                {
                    updatedEntity = gradeRepository.Update(grade);
                }

                return updatedEntity;
            }));
        }
Example #2
0
        public void Add(Grade grade)
        {
            ValidateGrade(grade);
            ValidateDuplicatedGrade(grade);

            _gradeRepository.Add(grade);
        }
Example #3
0
        public Task <GradeDTO> Handle(NovaGradeCommand request, CancellationToken cancellationToken)
        {
            var grade = request.Grade;

            var gradeBanco = gradeRepository.GetById(grade.CodGrade);

            if (gradeBanco != null)
            {
                throw new ValidacaoException($"Já existe uma cadastrada com o codGrade {grade.CodGrade}!");
            }

            var professor = professorRepository.GetByCodFuncionarioIncludeUsuario(grade.CodFuncionario);

            if (professor == null)
            {
                throw new NaoEncontradoException("Professor não encontrado através do codFuncionario informado!");
            }

            grade.Cpf            = professor.Cpf;
            grade.CodFuncionario = professor.CodFuncionario;

            grade = gradeRepository.Add(grade);

            GradeDTO gradeDTO = new GradeDTO()
            {
                CodGrade       = grade.CodGrade,
                Turma          = grade.Turma,
                Disciplina     = grade.Disciplina,
                Curso          = grade.Curso,
                CodFuncionario = grade.CodFuncionario
            };

            return(Task.FromResult(gradeDTO));
        }
Example #4
0
        public Task <bool> Handle(NovaMatriculaCommand request, CancellationToken cancellationToken)
        {
            var matricula = request.AlunoGrade;

            var grade = gradeRepository.GetByIdIncludeAlunos(matricula.CodGrade);

            if (grade == null)
            {
                throw new NaoEncontradoException("Grade não encontrada através do codGrade informado!");
            }

            if (grade.GradeAlunos.Where(ga => ga.Ra == matricula.Ra).Any())
            {
                throw new ValidacaoException($"O aluno com RA {matricula.Ra} já está matriculado na grade {matricula.CodGrade}!");
            }

            var subGrade = gradeRepository.GetSubGrades(grade).Where(g => g.GradeAlunos.Where(ga => ga.Ra == matricula.Ra).Any()).FirstOrDefault();

            if (subGrade != null)
            {
                throw new ValidacaoException($"O aluno com RA {matricula.Ra} já está matriculado na grade {subGrade.CodGrade}, que é uma subgrade da grade {grade.CodGrade}!");
            }

            var aluno = alunoRepository.GetByRaIncludeUsuario(matricula.Ra);

            if (aluno == null)
            {
                throw new NaoEncontradoException("Aluno não encontrado através da RA informada!");
            }

            matricula.Cpf = aluno.Cpf;

            if (grade.GradeAlunos.Count < 10)
            {
                grade.GradeAlunos.Add(matricula);
                gradeRepository.Update(grade);
            }
            else
            {
                subGrade = gradeRepository.GetSubGrade(grade);
                if (subGrade != null)
                {
                    subGrade.GradeAlunos.Add(matricula);
                    gradeRepository.Update(subGrade);
                }
                else
                {
                    var idGrade   = gradeRepository.GetAll().Max(g => g.CodGrade) + 1;
                    var novaGrade = new Grade(idGrade, grade.Turma, grade.Disciplina, grade.Curso, grade.CodFuncionario)
                    {
                        Cpf = grade.Cpf
                    };
                    novaGrade.GradeAlunos.Add(matricula);
                    gradeRepository.Add(novaGrade);
                }
            }

            return(Task.FromResult(true));
        }
Example #5
0
 public IHttpActionResult AddGrade(Grade grade)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     repository.Add(grade);
     return(CreatedAtRoute("DefaultApi", new { id = grade.GradeId }, grade));
 }
Example #6
0
        public Grade Add(Grade newGrade)
        {
            if (_gradeRepository.SearchGradesBy(0, newGrade.StudentId, newGrade.SubjectId).Any())
            {
                return(null);
            }
            var created = _gradeRepository.Add(newGrade);

            return(created);
        }
Example #7
0
        public async Task <bool> Insert(Grade grade)
        {
            try
            {
                var status = await _repository.Add(grade);

                return(status);
            }
            catch (OzoneException ex)
            {
                throw new OzoneException(ex.Message, ex.InnerException);
            }
        }
Example #8
0
        public async Task <MessageModel <string> > Post([FromBody] Grade Grade)
        {
            var data = new MessageModel <string>();

            var id = await _iGradeRepository.Add(Grade);

            data.success = id > 0;
            if (data.success)
            {
                data.response = id.ObjToString();
                data.msg      = "添加成功";
            }

            return(data);
        }
        public void Add(Homework homework, User student, float mark)
        {
            var item = gradeRepository.getByUserIdAndAssignmentId(student.UserID.ToString(), homework.Assignment.AssignmentID.ToString());

            if (item == null)
            {
                gradeRepository.Add(new Grades()
                {
                    Id = Guid.NewGuid(), StudentId = student, Homework = homework, Mark = mark
                });
            }
            else
            {
                item.Mark = mark;
                gradeRepository.Update(item);
            }
        }
        public async Task <dynamic> Add(GradeRequest gradeRequest)
        {
            if (gradeRequest == null)
            {
                AddError("20000");
                return(null);
            }

            var grade = Grade.Create(gradeRequest.Name);

            //if (!user.IsValid)
            //{
            //    Error = user.Error;
            //    return null;
            //}

            _gradeRepository.Add(grade);
            return(await Task.FromResult(grade));
        }
Example #11
0
        public void CreateExam(Exam exam)
        {
            if (_examRepository.GetById(exam.Id) != null)
            {
                throw new ArgumentOutOfRangeException();
            }
            _examRepository.Add(exam);

            foreach (var stud in _studentRepository.GetAll())
            {
                foreach (var course in _courseRepository.GetAll())
                {
                    if (stud.StudyYear == course.StudyYear && course.Id == exam.CourseId)
                    {
                        var grade = new Grade(stud.Id, exam.Id, 0, 0);
                        _gradeRepostory.Add(grade);
                    }
                }
            }
        }
 public async Task AddGrade(GradeAddDto grade)
 {
     await _gradeRepository.Add(_mapper.Map <Grade>(grade));
 }
Example #13
0
 public void CreateGrade(Grade grade)
 {
     _gradeRepository.Add(grade);
 }