コード例 #1
0
        public override async Task <bool> Editar(Aluno entidade)
        {
            if (!ExecutarValidacao(new AlunoValidacoes(), entidade))
            {
                return(false);
            }
            await _repositorio.Editar(entidade);

            return(true);
        }
コード例 #2
0
        public async Task <IComandoResultado> ManipuladorAsync(EditarAlunoComando comando)
        {
            //Valiadar vo
            var email = new Vo.Email(comando.Email);

            AddNotifications(email.Notifications);
            if (!string.IsNullOrEmpty(comando.Cpf))
            {
                var cpf = new Vo.Cpf(comando.Cpf);
                AddNotifications(cpf.Notifications);
            }

            //Criar Entidade
            var aluno = new AcademiaDanca.Dominio.Contexto.Entidade.Aluno(comando.Id, comando.Nome, comando.DataNascimento, null, email, comando.UifId, comando.Telefone, comando.Celular, null, comando.Cpf, null);

            AddNotifications(aluno.Notifications);

            //Validar ocorreu mudanca nos dados
            var alunoQuery = await _repositorio.ObterPorAsync(comando.Id);

            var alunoAtual = new AcademiaDanca.Dominio.Contexto.Entidade.Aluno(alunoQuery.AlunoId, alunoQuery.AlunoNome, alunoQuery.AlunodataNascimento, null,
                                                                               new Vo.Email(alunoQuery.AlunoEmail), new Guid(alunoQuery.AlunoGuid), alunoQuery.AlunoTelefone, alunoQuery.AlunoCelular, null, alunoQuery.AlunoCpf, null);

            if (!aluno.Equals(alunoAtual))
            {
                AddNotification("", "Sem dados para atualizar no momento.");
            }

            if (Invalid)
            {
                return(new ComandoResultado(
                           false,
                           "Por favor, corrija os campos abaixo",
                           Notifications));
            }

            //Persistir os dados

            await _repositorio.Editar(aluno);

            // Retornar o resultado para tela
            return(new ComandoResultado(true, "Funcionario cadastrado com sucesso", new
            {
                Id = 0,
                Nome = "",
                Status = true
            }));
        }
コード例 #3
0
        public void Aluno_InfraData_Atualizar_Sucesso()
        {
            int id = 1;

            _aluno      = _alunoRepositorio.Buscar(id);
            _aluno.Nome = "Ana";

            _alunoRepositorio.Editar(_aluno);

            Aluno alunoBuscado = _alunoRepositorio.Buscar(_aluno.Id);

            alunoBuscado.Id.Should().Be(_aluno.Id);
            alunoBuscado.Nome.Should().Be(_aluno.Nome);
            alunoBuscado.Endereco.Rua.Should().Be(_aluno.Endereco.Rua);
            alunoBuscado.Endereco.Numero.Should().Be(_aluno.Endereco.Numero);
        }