Esempio n. 1
0
        public int AgregarCliente(Cliente cliente)
        {
            ResultadoTransaccion resultado = _clienteMapper.Insert(cliente);

            if (resultado.IsOk)
            {
                return(resultado.Id);
            }
            else
            {
                throw new Exception("Hubo un error en la petición al servicior. Detalle: " + resultado.Error);
            }
        }
Esempio n. 2
0
        public int AgregarCliente()
        {
            TransactionResult result = clienteMapper.Insert(new Cliente(400, 41063486, "Augusto", "Falsone", "Falsa 123", "12334545", "*****@*****.**", "03-27-1998"));

            if (result.IsOk)
            {
                return(result.Id);
            }
            else
            {
                throw new Exception("Ocurrió un error en el servidor, " + result.Error);
            }
        }
Esempio n. 3
0
        public int InsertarCliente(Cliente cliente)
        {
            TransactionResult resultante = mapper.Insert(cliente);

            if (resultante.IsOk)
            {
                return(resultante.Id);
            }
            else
            {
                throw new Exception("Hubo un error en la petición al servidor. Detalle: " + resultante.Error);
            }
        }
Esempio n. 4
0
        public int InsertarCliente(int dni, string nombre, string apellido, string email, string telefono, DateTime fechanacimiento, bool activo, int id)
        {
            Cliente c = new Cliente(dni, nombre, apellido, email, telefono, fechanacimiento, id);

            TransactionResult transaccion = mapper.Insert(c);

            if (transaccion.IsOk)
            {
                return(transaccion.Id);
            }
            else
            {
                throw new Exception("ha habido un error al crear cliente" + transaccion.Error);
            }
        }
        public int IngresarCliente(string nombre, string apellido, DateTime fechaNacimiento, string direccion, string telefono, string mail, bool activo, int dni)
        {
            List <Cliente> clientes       = this.GetClientes();
            int            idNuevoCliente = this.UltimoCodCliente() + 1;

            if (fechaNacimiento.Date >= DateTime.Now.Date)
            {
                throw new Exception("La fecha de nacimiento no puede ser mayor a la actual");
            }
            if (int.TryParse(telefono, out int telefono2) == false)
            {
                throw new Exception("El teléfono debe ser un valor numérico");
            }
            if (string.IsNullOrEmpty(nombre) || string.IsNullOrEmpty(apellido) || string.IsNullOrEmpty(telefono) || string.IsNullOrEmpty(mail) || string.IsNullOrEmpty(direccion))
            {
                throw new Exception("Hay campos sin completar");
            }

            //Cliente cliente = new Cliente(idNuevoCliente, DateTime.Now.ToShortDateString(), fechaNacimiento.ToShortDateString(), activo,dni, nombre, apellido, direccion, telefono, mail);
            Cliente cliente = new Cliente(idNuevoCliente, DateTime.Now.ToString("yyyy-MM-dd"), fechaNacimiento.ToString("yyyy-MM-dd"), activo, dni, nombre, apellido, direccion, telefono, mail);

            foreach (Cliente c in clientes)
            {
                if (c.Nombre?.ToUpper() == cliente.Nombre?.ToUpper() && c.Apellido?.ToUpper() == cliente.Apellido?.ToUpper())
                {
                    throw new Exception(string.Format("Ya existe un cliente llamado \"{0} {1}\"", nombre, apellido));
                }
                if (c.Telefono == cliente.Telefono || c.Email?.ToUpper() == cliente.Email?.ToUpper())
                {
                    throw new Exception(string.Format("El email \"{0}\" o el teléfono \"{1}\" se encuentran ya registrados.", mail, telefono));
                }
            }

            TransactionResult result = clienteMapper.Insert(cliente);

            if (result.IsOk)
            {
                this._clientes.Add(cliente);
                return(result.Id);
            }
            else
            {
                throw new Exception(string.Format("Ocurrió un error en el servidor. Detalle: \"{0}\"", result.Error));
            }
        }
        public int IngresarCliente(Cliente item)
        {
            if (_listaclientes.Any(o => o.Dni == item.Dni))
            {
                throw new ReservasException("El DNI se encuentra registrado");
            }
            TransactionResult resultado = ClienteMapper.Insert(item);

            if (resultado.IsOk)
            {
                ClienteCache();
                return(resultado.Id);
            }
            else
            {
                throw new ReservasException(resultado.Error);
            }
        }
Esempio n. 7
0
        public int InsertarCliente(string nombre, string apellido, string direccion)
        {
            Cliente cliente = new Cliente();

            cliente.Ape       = apellido;
            cliente.Nombre    = nombre;
            cliente.Direccion = direccion;

            TransactionResult resultante = mapper.Insert(cliente);

            if (resultante.IsOk)
            {
                return(resultante.Id);
            }
            else
            {
                throw new Exception("Hubo un error en la petición al servidor. Detalle: " + resultante.Error);
            }
        }
Esempio n. 8
0
 public static void InsertarCliente(Cliente cliente)
 {
     if (ExisteCliente(cliente))
     {
         throw new ClienteExistenteException(cliente.Id);
     }
     else
     {
         TransactionResult result = ClienteMapper.Insert(cliente);
         if (!result.IsOk)
         {
             throw new ErrorServidorException(result.Error);
         }
         else
         {
             RefrescarCache();
         }
     }
 }
 public void InsertarCliente(Cliente cliente)
 {
     if (ExisteElCliente(cliente))
     {
         throw new ClienteExistenteException(cliente.ID);
     }
     else
     {
         TransactionResult resultante = mapper.Insert(cliente);
         if (!resultante.IsOk)
         {
             throw new Exception("Hubo un error en la petición al servidor. Detalle: " + resultante.Error);
         }
         else
         {
             RefrescarCache();
         }
     }
 }
Esempio n. 10
0
        public int IngresarCliente(Cliente cliente)
        {
            string regla = Reglas(cliente);

            if (!string.IsNullOrEmpty(regla))
            {
                throw new Exception(regla);
            }
            else
            {
                TransactionResult resultado = ClienteMapper.Insert(cliente);
                if (resultado.IsOk)
                {
                    RecargarLista();
                    return(resultado.Id);
                }
                else
                {
                    throw new Exception(resultado.Error);
                }
            }
        }
        public int InsertarCliente(string nombre, string apellido, string direccion, string email, string telefono, DateTime fechaNacimiento)
        {
            Cliente cliente = new Cliente();

            cliente.Apellido        = apellido;
            cliente.Nombre          = nombre;
            cliente.Direccion       = direccion;
            cliente.Email           = email;
            cliente.Telefono        = telefono;
            cliente.FechaNacimiento = fechaNacimiento;
            cliente.Activo          = true;
            TransactionResult resultante = mapper.Insert(cliente);

            if (resultante.IsOk)
            {
                return(resultante.Id);
            }
            else
            {
                throw new Exception("Hubo un error en la petición al servidor. Detalle: " + resultante.Error);
            }
        }
        public int InsertarCliente(Cliente cli)
        {
            List <Cliente> result = mapper.TraerTodos();

            foreach (Cliente C in result) // valida el negocio que no este ya cargado
            {
                if (cli.Dni == C.Dni)
                {
                    throw new Exception("El cliente ya existe");
                }
            }

            TransactionResult resultado = mapper.Insert(cli);

            if (!resultado.IsOk)
            {
                throw new Exception("Hubo un error en la petición al servidor.Detalle: " + resultado.Error);
            }
            else
            {
                return(resultado.Id);
            }
        }
Esempio n. 13
0
        public int InsertarCliente(string dni, string nombre, string apellido, string direccion, string email, string telefono, DateTime fechaNacimiento)
        {
            // antes validar con el get si existe ese dni/apellido-nombre
            List <Cliente> result = mapper.TraerTodos();

            Cliente cliente = new Cliente();

            cliente.Ape             = apellido;
            cliente.Nombre          = nombre;
            cliente.Direccion       = direccion;
            cliente.Dni             = dni;
            cliente.email           = email;
            cliente.Telefono        = telefono;
            cliente.FechaNacimiento = fechaNacimiento;
            cliente.Activo          = true;

            foreach (var item in result)
            {
                if (item.ToString() == cliente.ToString())
                {
                    throw new Exception("El cliente ya existe");
                }
            }

            // ya pasamos las validaciones, persistimos el cliente
            TransactionResult resultante = mapper.Insert(cliente);

            if (resultante.IsOk)
            {
                return(resultante.Id);
            }
            //return TraerClientesPorId(resultante.Id);
            else
            {
                throw new Exception("Hubo un error en la petición al servidor. Detalle: " + resultante.Error);
            }
        }