Ejemplo n.º 1
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            if (value == null)
            {
                return(new ValidationResult("Digite o CPF!"));
            }
            string cpf = (value as string).Trim();

            IClienteServices clienteRepos = (IClienteServices)validationContext.GetService(typeof(IClienteServices));
            List <Cliente>   clientes     = clienteRepos.GetUserByCPFAsync(cpf).Result;

            ClienteDTO objCliente = (ClienteDTO)validationContext.ObjectInstance;

            if (clientes.Count > 1)
            {
                return(new ValidationResult("CPF já existente!"));
            }
            if (clientes.Count == 1 && objCliente.CPF != clientes.First().CPF)
            {
                return(new ValidationResult("CPF já existente!"));
            }


            return(ValidationResult.Success);
        }
 public UsersController(
     IClienteServices userService,
     IOptions <AppSettings> appSettings)
 {
     _userService = userService;
     _appSettings = appSettings.Value;
 }
Ejemplo n.º 3
0
        public static void AtualizarCliente(IClienteServices clienteService)
        {
            Console.Clear();
            Console.Write("Digite o id do cliente que deseja atualizar: ");
            var idString = Console.ReadLine();
            int?id;

            if (idString == string.Empty)
            {
                id = null;
            }
            else
            {
                id = int.Parse(idString);
            }

            var cliente = clienteService.ObterClientes(id).First();

            Console.WriteLine(cliente);

            Console.Write("Digite o novo nome(digite nada para não alterar): ");
            string nome = Console.ReadLine();

            Console.Write("Digite o novo login(digite nada para não alterar): ");
            string login = Console.ReadLine();

            Console.Write("Digite a nova senha(digite nada para não alterar): ");
            string senha = Console.ReadLine();

            nome  = nome != string.Empty ? nome : cliente.Nome;
            login = login != string.Empty ? login : cliente.Login;
            senha = senha != string.Empty ? senha : cliente.Senha;

            Console.WriteLine(clienteService.AtualizarCliente(id.Value, nome, login, senha));
        }
Ejemplo n.º 4
0
 public EmprestimoServices(IEmprestimoRepository emprestimoRepository, IClienteServices clienteServices, IEmprestimoBuilder emprestimoBuilder, IValidator <EmprestimoFormDto> validatorFormDto)
 {
     _emprestimoRepository = emprestimoRepository;
     _clienteServices      = clienteServices;
     _emprestimoBuilder    = emprestimoBuilder;
     _validatorFormDto     = validatorFormDto;
 }
Ejemplo n.º 5
0
        public ActionResult Delete([FromServices] IClienteServices clienteServices, int id)
        {
            try
            {
                clienteServices.DeleteClienteById(id);

                return(Ok());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message, ex);
                return(Problem(ex.Message));
            }
        }
Ejemplo n.º 6
0
        public ActionResult Put([FromServices] IClienteServices clienteServices, [FromBody] Cliente cliente)
        {
            try
            {
                clienteServices.SalvarCliente(cliente);

                return(Ok());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message, ex);
                return(Problem(ex.Message));
            }
        }
Ejemplo n.º 7
0
        public ActionResult GetAll([FromServices] IClienteServices clienteServices)
        {
            try
            {
                var cliente = clienteServices.GetAllCliente().ToList();

                return(Ok(cliente));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message, ex);
                return(Problem(ex.Message));
            }
        }
Ejemplo n.º 8
0
        public ActionResult Get([FromServices] IClienteServices clienteServices, long id)
        {
            try
            {
                var cliente = clienteServices.GetClienteById(id);

                return(Ok(cliente));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message, ex);
                return(Problem(ex.Message));
            }
        }
Ejemplo n.º 9
0
        public static void DeletarCliente(IClienteServices clienteService)
        {
            Console.Clear();
            Console.Write("Digite o id do cliente que deseja deletar: ");
            var idString = Console.ReadLine();
            int?id;

            if (idString == string.Empty)
            {
                id = null;
            }
            else
            {
                id = int.Parse(idString);
            }

            Console.WriteLine(clienteService.DeletarCliente(id));
        }
Ejemplo n.º 10
0
        public static void CadastrarCliente(IClienteServices clienteService)
        {
            Console.Clear();
            Console.Write("Digite o id: ");
            int id = int.Parse(Console.ReadLine());

            Console.Write("Digite o nome: ");
            string nome = Console.ReadLine();

            Console.Write("Digite o login: "******"Digite a senha: ");
            string senha = Console.ReadLine();

            var cliente = clienteService.CadastrarCliente(id, nome, login, senha);

            Console.WriteLine(cliente);
        }
Ejemplo n.º 11
0
        public static void ObterCliente(IClienteServices clienteService)
        {
            Console.Clear();
            Console.Write("Informe o id, caso queria um cliente específico: ");
            var idString = Console.ReadLine();
            int?id;

            if (idString == string.Empty)
            {
                id = null;
            }
            else
            {
                id = int.Parse(idString);
            }

            var clientes = clienteService.ObterClientes(id);

            foreach (Cliente x in clientes)
            {
                Console.WriteLine(x);
            }
        }
Ejemplo n.º 12
0
 public Form1(IClienteServices clienteServices)
 {
     InitializeComponent();
     _clienteServices = clienteServices;
 }
Ejemplo n.º 13
0
 public VidaRealController(IClienteServices clienteServices)
 {
     _clienteServices = clienteServices;
 }
Ejemplo n.º 14
0
 public ClienteController(IClienteServices clienteServices)
 {
     _clienteServices = clienteServices;
 }
Ejemplo n.º 15
0
 public TesteDip()
 {
     _cliService = new ClienteServices(new EmailServices(), new ClienteRepository());
 }
 public void Index([FromServices] IClienteServices clienteServices)
 {
     clienteServices.AdicionarCliente(new Cliente());
 }
 public ClientesController(IClientes cliente, IHttpClientFactory client, IClienteServices clienteSvc)
 {
     _client     = cliente;
     _httpClient = client.CreateClient("AltioraService");
     _clienteSvc = clienteSvc;
 }
Ejemplo n.º 18
0
 public ClienteController(IClienteServices _clienteServices)
 {
     this.clienteServices = _clienteServices;
 }
Ejemplo n.º 19
0
 public ClienteController(IClienteServices prmClienteServices, ILogger <ClienteController> logger,
                          IOptions <AppSettings> settings)
 {
     clienteServices = prmClienteServices;
     _logger         = logger;
 }
Ejemplo n.º 20
0
 public HomeController(ILogger <HomeController> logger, IClienteServices _clienteServices)
 {
     _logger          = logger;
     _ClienteServices = _clienteServices;
 }
 public ClienteController(IClienteServices clienteServices, IEmprestimoServices emprestimoServices)
 {
     _clienteServices    = clienteServices;
     _emprestimoServices = emprestimoServices;
 }
 public ClienteController(IClienteServices services, IMapper mapper)
 {
     _services = services;
     _mapper   = mapper;
 }
Ejemplo n.º 23
0
 public ClientesController(IClienteServices service)
 {
     _service = service;
 }
Ejemplo n.º 24
0
 public ClientesController(IClienteServices IClienteServices)
 {
     _IClienteServices = IClienteServices;
 }
 public DeleteModel(IClienteServices clienteServices)
 {
     _clienteServices = clienteServices;
 }
Ejemplo n.º 26
0
 public ClienteAppServices(IClienteServices clienteServices, IMapperServices mapper)
 {
     _clienteServices = clienteServices;
     _mapper          = mapper;
 }
Ejemplo n.º 27
0
 public ClientesController(IClienteServices clienteServices,
                           IMapper mapper)
 {
     _clienteServices = clienteServices;
     _mapper          = mapper;
 }
Ejemplo n.º 28
0
 public ClienteController(IClienteServices clienteServices, IUsuarioServices usuarioServices)
 {
     this.clienteServices = clienteServices;
     this.usuarioServices = usuarioServices;
 }
Ejemplo n.º 29
0
 public ClienteController(ILogger <ClienteController> logger, IClienteServices clienteServices)
 {
     _logger          = logger;
     _clienteServices = clienteServices;
 }