Ejemplo n.º 1
0
        private async Task <bool> Modificar()
        {
            bool    modificado = false;
            Cliente C          = new Cliente()
            {
                Dni       = textDni.Text,
                Nombre    = textNombreApellido.Text,
                Telefono  = textTelefono.Text,
                Domilicio = textDomicilio.Text
            };

            ValidacionCliente validator = new ValidacionCliente();
            ValidationResult  results   = validator.Validate(C);

            if (!results.IsValid)
            {
                string mensaje = results.Errors[0].ErrorMessage;
                MessageBox.Show(mensaje);
            }
            else
            {
                try
                {
                    modificado = await _repositorioCliente.Modificar(C);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            return(modificado);
        }
Ejemplo n.º 2
0
        private async Task <bool> Crear()
        {
            bool    creado = false;
            Cliente C      = new Cliente()
            {
                Dni       = textDni.Text,
                Nombre    = textNombreApellido.Text,
                Telefono  = textTelefono.Text,
                Domilicio = textDomicilio.Text
            };

            ValidacionCliente validator = new ValidacionCliente();
            ValidationResult  results   = validator.Validate(C);

            if (!results.IsValid)
            {
                string mensaje = results.Errors[0].ErrorMessage;
                MessageBox.Show(mensaje);
            }
            else
            {
                try
                {
                    creado = await _repositorioCliente.Crear(C);
                }
                catch (DniYaExisteException dyee)
                {
                    MessageBox.Show(dyee.Message);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("ocurrió un error.");
                }
            }
            return(creado);
        }