Exemplo n.º 1
0
        public async Task <int> IncluirNovoProfessorAsync(string email, string nome)
        {
            var professor = new Professor()
            {
                Nome = nome, Email = email
            };

            _professorRepository.Adicionar(professor);
            await _professorRepository.SaveChangesAsync();

            return(professor.Id);
        }
Exemplo n.º 2
0
        public async Task Adicionar(ProfessorViewModel professorViewModel)
        {
            var professor = _mapper.Map <Professor>(professorViewModel);

            if (!ExecutarValidacao(new ProfessorValidation(), professor))
            {
                return;
            }

            if (_professorRepository.Buscar(r => r.Cpf == professor.Cpf).Result.Any())
            {
                Notificar("Já existe um professor cadastrado com o CPF informado.");
                return;
            }

            _professorRepository.Adicionar(professor);
            await _professorRepository.UnitOfWork.Commit();
        }
Exemplo n.º 3
0
        public string Salvar(Professor professor)
        {
            try
            {
                //Inserir e o Alterar

                if (professor.IdPessoa == 0)
                {
                    ProfessorRepository.Adicionar(professor);
                }
                else
                {
                    ProfessorRepository.Alterar(professor);
                }

                ProfessorRepository.SalvarAlteracoes();

                return(null);
            }catch (Exception ex)
            {
                return(ex.Message);
            }
        }