public ClienteController(IClienteRepository clienteRepository)
 {
     _criarCliente     = new CriarCliente(clienteRepository);
     _alterarCliente   = new AlterarCliente(clienteRepository);
     _consultarCliente = new ConsultarCliente(clienteRepository);
     _excluirCliente   = new ExcluirCliente(clienteRepository);
 }
        public async Task <IActionResult> Post([FromBody]  CriarCliente model, CancellationToken cancellationToken)
        {
            var resultado = await _bus.Send(model, cancellationToken);

            if (resultado.Sucesso)
            {
                return(Ok(resultado.Mensagem));
            }
            return(BadRequest(resultado.Mensagem));
        }
示例#3
0
        public async Task DeveRetornarBadRequest_Quando_CriarClienteComSucesso()
        {
            //arrange
            var command = new CriarCliente();

            _bus.Setup(p => p.Send(command, _cancellationToken)).ReturnsAsync(new Resultado(false, "Ocorreu um erro."));

            //act
            var resultado = await _controller.Post(command, _cancellationToken);

            //assert
            Assert.IsType <BadRequestObjectResult>(resultado);
        }
示例#4
0
        public async Task DeveRetornarOk_Quando_CriarClienteComSucesso()
        {
            //arrange
            var command  = new CriarCliente();
            var response = new Resultado(true, "Cliente criado com sucesso.");

            _bus.Setup(p => p.Send(command, _cancellationToken)).ReturnsAsync(new Resultado(true, "Cliente criado com sucesso."));

            //act
            var resultado = await _controller.Post(command, _cancellationToken);

            //assert
            Assert.IsType <OkObjectResult>(resultado);
        }
示例#5
0
        private void BtnClientes_Click(object sender, RoutedEventArgs e)
        {
            CriarCliente criarCliente = new CriarCliente();

            criarCliente.Show();
        }