コード例 #1
0
        public async Task AlterarPessoaEstudante()
        {
            var cmdCriaEstudante = CriarComandoDeCriarEstudante();

            await CriarEstudante(cmdCriaEstudante);


            var cmd = new AlterarPessoaCommand()
            {
                Id             = cmdCriaEstudante.Id,
                Username       = Fixture.Create <string>(),
                Nome           = Fixture.Create <string>(),
                CPF            = Fixture.Create <string>(),
                DataNascimento = Fixture.Create <DateTime>()
            };

            var response = await DoPostRequest("/Pessoa/AlterarPessoa", cmd);

            var estudante = _f7DbContext.PessoaUsuarioDbSet.FirstOrDefault(x => x.Id == cmd.Id);

            estudante.Should().NotBeNull();

            response.StatusCode.Should().Be(HttpStatusCode.OK);
            estudante.Nome.Should().Be(cmd.Nome);
            estudante.Username.Should().Be(cmd.Username);
            estudante.CPF.Should().Be(cmd.CPF);
            estudante.DataNascimento.Should().Be(cmd.DataNascimento);
        }
コード例 #2
0
        public Task <Unit> Handle(AlterarPessoaCommand request, CancellationToken cancellationToken)
        {
            var student = _f7DbContext.PessoaUsuarioDbSet.FirstOrDefault(x => x.Id == request.Id);

            student.Nome           = request.Nome;
            student.Username       = request.Username;
            student.CPF            = request.CPF;
            student.DataNascimento = request.DataNascimento;
            student.Perfil         = student.Perfil;
            _f7DbContext.SaveChanges();

            return(Unit.Task);
        }
コード例 #3
0
ファイル: PessoaController.cs プロジェクト: fraidev/F7System
 public IActionResult AlterarPessoa([FromBody] AlterarPessoaCommand cmd)
 {
     _mediator.Send(cmd);
     return(Ok());
 }