Example #1
0
        private RepresentanteLegal representanteLegal()
        {
            Identidad          identidadRepresentante = new Identidad("0801198512396");
            RepresentanteLegal representanteLegal     = new RepresentanteLegal(identidadRepresentante, "Juan Perez");

            return(representanteLegal);
        }
        private static Beneficiario getBeneficiario(Identidad identidad, Nombre nombre, DateTime fechaNacimiento)
        {
            var beneficiario = new Beneficiario(identidad,
                                                nombre, fechaNacimiento);

            return(beneficiario);
        }
Example #3
0
        private void cerrarSesiónToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Identidad.Limpiar();

            lblNombre.Text              = string.Empty;
            lblApellido.Text            = string.Empty;
            imgFotoUsuarioLogin.Image   = null;
            imgFotoUsuarioLogin.Visible = false;

            var fLogin = ObjectFactory.GetInstance <Login>();

            fLogin.ShowDialog();

            if (fLogin.PuedeIngresar)
            {
                imgFotoUsuarioLogin.Visible = true;
                lblApellido.Text            = $"{Identidad.Apellido}";
                lblNombre.Text            = $"{Identidad.Nombre}";
                imgFotoUsuarioLogin.Image = Imagen.ConvertirImagen(Identidad.Foto);
                Perfil();
            }
            else
            {
                Application.Exit();
            }
        }
Example #4
0
        public Empleo getEmpleoMasRecienteBeneficiario(Identidad identidad)
        {
            return((Session.QueryOver <Empleo>()

                    .Where(x => x.Beneficiario.Id == identidad)
                    .OrderBy(x => x.FechaDeInicio).Desc
                    .List <Empleo>()).FirstOrDefault());
        }
        internal ModeloLectura(ILector lector, IObjetoDatos od)
        {
            _lector       = lector;
            _od           = od;
            _stack        = new Identidad();
            _asociaciones = new List <IMetodoAsociacion>();

            ConstruirTipos();
        }
 public ModeloEscritura(IEscritor escritor, IObjetoDatos od)
 {
     _escritor = escritor;
     _stack    = new Identidad();
     _od       = new List <IObjetoDatos>()
     {
         od
     };
 }
Example #7
0
        public IEnumerable <Empleo> getEmpleosByBeneficiario(Identidad identidad)
        {
            return(from empleo in Session.Query <Empleo>()
                   where
                   empleo.Beneficiario.Id == identidad

                   select empleo

                   );
        }
Example #8
0
        public void constructor_nombreNulo_lanzaExcepcion()
        {
            var nombreRepresentanteNulo = string.Empty;
            var identidad = new Identidad("0801198512396");

            Assert.Throws <ArgumentException>(() =>
            {
                new RepresentanteLegal(identidad, nombreRepresentanteNulo);
            }, "Nombre de Representante no puede ser nulo");
        }
Example #9
0
        private void iniciarSesionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Identidad.Usuario == null || Identidad.Usuario == string.Empty)
            {
                ObjectFactory.GetInstance <Presentacion.Core.Sesion.InicioSesion>().ShowDialog();
                Verificacion();
                return;
            }

            Identidad.Limpiar();
            Verificacion();
        }
        public void Test_Repo_Identidad_CreacionInstancia_Identidad()
        {
            RepositorioIdentidad repositorioIdentidad = new RepositorioIdentidad();
            Identidad            identidadAdmin       = repositorioIdentidad.getById(1);
            Identidad            identidadUnCliente   = repositorioIdentidad.getById(10);

            Assert.AreEqual("Usuario", identidadAdmin.getTipoIdentidad());
            Assert.AreEqual("Cliente", identidadUnCliente.getTipoIdentidad());

            Assert.AreEqual(1, identidadAdmin.getDirecciones().Count);
            Assert.AreEqual(1, identidadUnCliente.getDirecciones().Count);
        }
Example #11
0
        private RepresentanteLegal getRepresentanteLegal(GremioRequest gremioRequest)
        {
            var rtnRequest             = gremioRequest.rtnRequest;
            var representanteRequest   = gremioRequest.representanteLegalRequest;
            var identidadRepresentante = representanteRequest.identidadRequest;
            var identidad = new Identidad(identidadRepresentante.identidad);



            var representanteLegal = new RepresentanteLegal(identidad, representanteRequest.nombre);

            return(representanteLegal);
        }
Example #12
0
        public bool existsEmpleoRecienteParaBeneficiario(Guid idEmpleo, DateTime fechaDeBusqueda, int days,
                                                         Identidad identidadBeneficiario)
        {
            var fechaBase = fechaDeBusqueda.AddDays(-days);

            return((from empleo in Session.Query <Empleo>()
                    where
                    empleo.Beneficiario.Id == identidadBeneficiario && empleo.FechaDeInicio > fechaBase && empleo.Id != idEmpleo
                    select empleo.Id
                    ).Any());

            ;
        }
Example #13
0
        public async Task <Object> PostLoginRequestAsync(Identidad identidad)
        {
            RestClient <Identidad> restClient = new RestClient <Identidad>("login");

            string jsonResult = await restClient.PostAsync(identidad);

            string status      = (string)JObject.Parse(jsonResult)["status"];
            var    jsonUsuario = JObject.Parse(jsonResult)["options"];

            if (status == "successful")
            {
                sesion = new Sesion();
                Usuario usuario = new Usuario();
                if (jsonUsuario["idUsuarios"] != null)
                {
                    sesion.idUsuarios = jsonUsuario["idUsuarios"].Value <int>();
                }
                if (jsonUsuario["nombre"] != null)
                {
                    sesion.firstName = jsonUsuario["nombre"].Value <string>();
                }
                if (jsonUsuario["apellido"] != null)
                {
                    sesion.lastName = jsonUsuario["apellido"].Value <string>();
                }
                if (jsonUsuario["foto"] != null)
                {
                    sesion.photo = jsonUsuario["foto"].Value <string>();
                }
                if (jsonUsuario["idRol"] != null)
                {
                    sesion.role = jsonUsuario["idRol"].Value <int>();
                }
                //var fb = DependencyService.Get<IFirebase>().getFirebaseUserId();
                //Debug.WriteLine(fb + "es el id de firebase");
                SesionService sesionService = new SesionService();
                //var resultfb = await sesionService.UpdateFirebaseIdToken(sesion.idUsuarios, (string)fb);
                await sesionService.SetSesionDbAsync(sesion);

                return("successful");
            }
            else
            {
                //no esta
                return("unsuccessful");
            }
        }
Example #14
0
        public IHttpActionResult InsertarInstitucion(string NombreIdentidad, string CorreoIdentidad)
        {
            Identidad identidad = new Identidad();


            var idd = (from r in db.Usuarios
                       where r.Correo == User.Identity.Name
                       select r.IdUsuario).First();

            var valid = (from d in db.Identidad
                         where d.IdUsuarios == idd
                         select d.NombreIndentidad).Count();


            if (valid == 0)
            {
                try
                {
                    if (ModelState.IsValid)
                    {
                        identidad.IdUsuarios = idd;



                        identidad.NombreIndentidad = NombreIdentidad;
                        identidad.CorreoIdentidad  = CorreoIdentidad;

                        db.Identidad.Add(identidad);
                        db.SaveChanges();

                        return(Json("Identidad registrado"));
                    }
                }
                catch (Exception ex)
                {
                    return(Json(ex.Message));
                }
            }
            else
            {
                return(Json("Esta identidad ya tiene un usuario"));
            }



            return(Ok());
        }
Example #15
0
        public BeneficiarioModuleQuery(IBeneficiarioRepositoryReadOnly repository)
        {
            Get["/enterprise/beneficiarios"] = parameters =>
            {
                var beneficiarios = repository.getAll();
                return(Response.AsJson(beneficiarios.Select(getShortBeneficiarioRequest).ToList()));
            };

            Get["/enterprise/beneficiarios/id="] = parameters =>
            {
                var id = this.Bind <IdentidadRequest>();
                if (id.isValidPost())
                {
                    var identidad    = new Identidad(id.identidad);
                    var beneficiario = repository.get(identidad);
                    return(Response.AsJson(getLongBeneficiarioRequest(beneficiario))
                           .WithStatusCode(HttpStatusCode.OK));
                }

                return(new Response()
                       .WithStatusCode(HttpStatusCode.BadRequest));
            };
        }
Example #16
0
        private RepresentanteLegal getRepresentanteLegal(string id)
        {
            var identidad = new Identidad(id);

            return(new RepresentanteLegal(identidad, "representante"));
        }
Example #17
0
 private bool isRepresentantExisting(Identidad id)
 {
     return(_representanteLegalRepositoryRead.exists(id));
 }
 private Dependiente getDependiente(Identidad identidad, Nombre nombre, Parentesco parentesco)
 {
     return(new Dependiente(identidad, nombre, parentesco, new DateTime(1984, 8, 2)));
 }
        private static RepresentanteLegal getRepresentante()
        {
            var identidadRepresentante = new Identidad("0801198512396");

            return(new RepresentanteLegal(identidadRepresentante, "Juan Perez"));
        }
        override public Cliente getById(int idCliente)
        {
            //Elementos del Cliente a devolver
            Cliente              cliente;
            int                  idIdentidad   = 0;
            Identidad            identidad     = null;
            RepositorioIdentidad repoIdentidad = new RepositorioIdentidad();
            Boolean              activo        = false;
            List <Reserva>       reservas      = new List <Reserva>();
            Boolean              inconsistente = false;

            //Configuraciones de la consulta
            String        connectionString = ConfigurationManager.AppSettings["BaseLocal"];
            SqlConnection sqlConnection    = new SqlConnection(connectionString);
            SqlCommand    sqlCommand       = new SqlCommand();
            SqlDataReader reader;

            //Primera Consulta
            sqlCommand.Parameters.AddWithValue("@idCliente", idCliente);
            sqlCommand.CommandType = CommandType.Text;
            sqlCommand.Connection  = sqlConnection;
            sqlCommand.CommandText = "SELECT * FROM LOS_BORBOTONES.Cliente WHERE idCliente = @idCliente";

            sqlConnection.Open();

            reader = sqlCommand.ExecuteReader();

            while (reader.Read())
            {
                idIdentidad   = reader.GetInt32(reader.GetOrdinal("IdIdentidad"));
                identidad     = repoIdentidad.getById(idIdentidad);
                activo        = reader.GetBoolean(reader.GetOrdinal("Activo"));
                inconsistente = reader.GetBoolean(reader.GetOrdinal("Inconsistente"));
            }

            //Cierro Primera Consulta
            sqlConnection.Close();

            //Si no encuentro elemento con ese ID tiro una excepción
            if (identidad.Equals(null))
            {
                throw new NoExisteIDException("No existe cliente con el ID asociado");
            }

            //Segunda Consulta
            sqlCommand.CommandText = @"
                
                SELECT r.idReserva
                FROM LOS_BORBOTONES.Reserva_X_Habitacion_X_Cliente rhc 
                INNER JOIN LOS_BORBOTONES.Reserva r ON r.idReserva = rhc.idReserva
                WHERE rhc.idCliente = @idCliente

            ";

            sqlConnection.Open();
            reader = sqlCommand.ExecuteReader();

            //Colecto las reservas
            while (reader.Read())
            {
                int idReserva = reader.GetInt32(reader.GetOrdinal("idReserva"));
                //RepositorioReserva repoReserva = new RepositorioReserva();
                //reservas.Add(repoReserva.getById(idReserva));
            }

            sqlConnection.Close();

            //Armo el cliente completo
            cliente = new Cliente(idCliente, identidad, activo, reservas, inconsistente);

            return(cliente);
        }
        //OPTIMIZO EL GETALL
        //NO TRAE LAS RESERVAS, POR EL MOMENTO
        //ASUMO QUE TENGO UNA SOLA DIRECCION SI TENGO MAS DE UNA ESTO ANDARIA MAL
        override public List <Cliente> getAll()
        {
            List <Cliente> clientes = new List <Cliente>();

            //Configuraciones de la consulta
            String        connectionString = ConfigurationManager.AppSettings["BaseLocal"];
            SqlConnection sqlConnection    = new SqlConnection(connectionString);
            SqlCommand    sqlCommand       = new SqlCommand();
            SqlDataReader reader;

            //Primera Consulta
            //ASUMO QUE TENGO UNA SOLA DIRECCION SI TENGO MAS DE UNA ESTO ANDARIA MAL
            sqlCommand.CommandType = CommandType.Text;
            sqlCommand.Connection  = sqlConnection;
            sqlCommand.CommandText = @" SELECT * 
                                        FROM LOS_BORBOTONES.Cliente c
                                        INNER JOIN LOS_BORBOTONES.Identidad i
                                        ON i.idIdentidad = c.idIdentidad
                                        INNER JOIN LOS_BORBOTONES.Direccion d
                                        ON d.idIdentidad = i.idIdentidad";

            sqlConnection.Open();

            reader = sqlCommand.ExecuteReader();

            while (reader.Read())
            {
                //ASUMO QUE TENGO UNA SOLA DIRECCION SI TENGO MAS DE UNA ESTO ANDARIA MAL
                Direccion direccion = new Direccion(reader.GetInt32(reader.GetOrdinal("idDireccion")),
                                                    reader.GetString(reader.GetOrdinal("Pais")),
                                                    reader.SafeGetString(reader.GetOrdinal("Ciudad")),
                                                    reader.GetString(reader.GetOrdinal("calle")),
                                                    reader.GetInt32(reader.GetOrdinal("NumeroCalle")),
                                                    reader.SafeGetInt32(reader.GetOrdinal("Piso")),
                                                    reader.SafeGetString(reader.GetOrdinal("Depto")));

                //ASUMO QUE TENGO UNA SOLA DIRECCION SI TENGO MAS DE UNA ESTO ANDARIA MAL
                List <Direccion> direcciones = new List <Direccion>();
                direcciones.Add(direccion);

                Identidad identidad = new Identidad(reader.GetInt32(reader.GetOrdinal("idIdentidad")),
                                                    reader.GetString(reader.GetOrdinal("TipoIdentidad")),
                                                    reader.GetString(reader.GetOrdinal("Nombre")),
                                                    reader.SafeGetString(reader.GetOrdinal("Apellido")),
                                                    reader.GetString(reader.GetOrdinal("TipoDocumento")),
                                                    reader.GetString(reader.GetOrdinal("NumeroDocumento")),
                                                    reader.GetString(reader.GetOrdinal("Mail")),
                                                    reader.SafeGetDateTime(reader.GetOrdinal("FechaNacimiento")),
                                                    reader.SafeGetString(reader.GetOrdinal("Nacionalidad")),
                                                    reader.GetString(reader.GetOrdinal("Telefono")),
                                                    direcciones);

                clientes.Add(new Cliente(reader.GetInt32(reader.GetOrdinal("idCliente")),
                                         identidad,
                                         reader.GetBoolean(reader.GetOrdinal("Activo")),
                                         new List <Reserva>(),
                                         reader.GetBoolean(reader.GetOrdinal("Inconsistente"))));
            }

            sqlConnection.Close();
            return(clientes);
        }
 public void Test_Repo_Identidad_getByIdFalla()
 {
     RepositorioIdentidad repositorioIdentidad = new RepositorioIdentidad();
     Identidad            identidad            = repositorioIdentidad.getById(999999999);
 }
Example #23
0
        public EmpleoModuleQuery(IEmpleoRepositoryReadOnly repositoryRead)
        {
            Get["/enterprise/empleos"] = parameters =>
            {
                var empleos = repositoryRead.getAll();
                return(Response.AsJson(getEmpleosRequests(empleos)));
            };

            Get["/enterprise/empleos/id={id}"] = parameters =>
            {
                var id = parameters.id;

                Guid idRequest;
                if (Guid.TryParse(id, out idRequest))
                {
                    if (Guid.Empty != idRequest)
                    {
                        var empleo = repositoryRead.get(idRequest);

                        return(Response.AsJson(getEmpleoRequest(empleo)));
                    }
                }

                return(new Response()
                       .WithStatusCode(HttpStatusCode.BadRequest));
            };


            Get["/enterprise/empleos/empresa/id={rtn}"] = parameters =>
            {
                var rtnRequest = new RTNRequest()
                {
                    RTN = parameters.rtn
                };
                if (rtnRequest.isValidPost())
                {
                    var rtn = new RTN(rtnRequest.RTN);
                    if (rtn.isRTNValid())
                    {
                        var empleos = repositoryRead.getEmpleosByEmpresa(rtn);
                        return(Response.AsJson(getEmpleosRequests(empleos)));
                    }
                }
                return(new Response()
                       .WithStatusCode(HttpStatusCode.BadRequest));
            };

            Get["/enterprise/empleos/beneficiario/id={identidad}"] = parameters =>
            {
                var identidadRequest = new IdentidadRequest()
                {
                    identidad = parameters.identidad
                };
                if (identidadRequest.isValidPost())
                {
                    var identidad = new Identidad(identidadRequest.identidad);
                    var empleos   = repositoryRead.getEmpleosByBeneficiario(identidad);
                    return(Response.AsJson(getEmpleosRequests(empleos)));
                }
                return(new Response()
                       .WithStatusCode(HttpStatusCode.BadRequest));
            };
        }
Example #24
0
        private void button2_Click(object sender, EventArgs e)
        {
            //GENERAR ALTA (no pido el estado ya que va como activo al momento de crearlo)

            //traigo los valores
            String   username        = textBoxUsername.Text.Trim();
            String   password        = textBoxPassword.Text.Trim();
            String   nombre          = textBoxNombre.Text.Trim();
            String   apellido        = textBoxApellido.Text.Trim();
            String   nroDoc          = textBoxNroDoc.Text.Trim();
            String   mail            = textBoxMail.Text.Trim();
            String   telefono        = textBoxTelefono.Text.Trim();
            String   calle           = textBoxCalle.Text.Trim();
            String   localidad       = textBoxLocalidad.Text.Trim();
            String   pais            = textBoxPaisOrigen.Text.Trim();
            String   nacionalidad    = textBoxNacionalidad.Text.Trim();
            DateTime fechaNacimiento = dateTime.Value;
            int      nroCalle        = 0;

            if (textBoxNroCalle.Text != "")
            {
                nroCalle = int.Parse(textBoxNroCalle.Text);
            }
            int nroPiso = 0;

            if (textBoxPiso.Text != "")
            {
                nroPiso = int.Parse(textBoxPiso.Text);
            }

            String  depto                 = textBoxDepto.Text.Trim();
            String  tipoDoc               = "";
            String  tipoIdentidad         = "Usuario";
            int     idDir                 = 0;
            int     idIdentidad           = 0;
            int     idUsuario             = 0;
            int     intentosFallidosLogin = 0;
            Boolean activo                = true;

            if (comboBoxTipoDoc.SelectedItem != null)
            {
                tipoDoc = (String)comboBoxTipoDoc.SelectedItem;
            }
            //traigo los roles elegidos
            List <Rol> roles = new List <Rol>();

            foreach (DataGridViewRow item in this.dataGridRoles.SelectedRows)
            {
                roles.Add(item.DataBoundItem as Rol);
            }
            //traigo los hoteles elegidos
            List <Hotel> hoteles = new List <Hotel>();

            foreach (DataGridViewRow item in this.dataGridHoteles.SelectedRows)
            {
                hoteles.Add(item.DataBoundItem as Hotel);
            }

            //armo direccion (id en 0)
            Direccion adress = new Direccion(idDir, pais, localidad,
                                             calle, nroCalle, nroPiso, depto);
            //armo la identidad con la direccion(id en 0)
            Identidad identidad = new Identidad(idIdentidad, tipoIdentidad, nombre, apellido, tipoDoc, nroDoc,
                                                mail, fechaNacimiento, nacionalidad, telefono, adress);
            // armo el usuario con la identidad (id en 0)
            Usuario user = new Usuario(idUsuario, identidad, username, password, intentosFallidosLogin, activo, roles, hoteles);
            //ahora si ya lo puedo crear
            RepositorioUsuario repoUser = new RepositorioUsuario();

            if (this.validoInput(this))
            {
                try
                {
                    repoUser.create(user);
                    MessageBox.Show("Usuario creado con éxito.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.limpiarPantalla();
                }
                //catch (ElementoYaExisteException exc)
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Verifique haber ingresado todos los datos necesarios para crear el usuario, incluyendo los roles que el usuario desempeña y los hoteles donde el usuario trabaja.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private static RepresentanteLegal getRepresentante(Identidad identidadRepresentante)
 {
     return(new RepresentanteLegal(identidadRepresentante, "Juan Perez"));
 }
Example #26
0
 private void salirToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Identidad.Limpiar();
     Close();
 }
        public EmpleoModuleQueryMovil(ISerializeJsonRequest serializerJson, Func <string, IEncrytRequestProvider> encryptRequestProvider,
                                      ITokenizer tokenizer, IEmpleoRepositoryReadOnly repositoryRead)
        {
            Post["/movil/empleo/id={identidad}/rtn={rtn}/sucursal={sucursal}"] = parameters =>
            {
                var movilRequest = this.Bind <MovilRequest>();
                try
                {
                    var userId = tokenizer.Detokenize(movilRequest.token, Context);
                    if (userId == null)
                    {
                        return(new Response().WithStatusCode(HttpStatusCode.Unauthorized));
                    }
                }
                catch (Exception e)
                {
                    return(new Response().WithStatusCode(HttpStatusCode.Unauthorized));
                }
                var token = movilRequest.token;

                string identidadFromClient = parameters.identidad;
                var    identidadRequest    = new IdentidadRequest()
                {
                    identidad = identidadFromClient
                };

                if (identidadRequest.isValidPost())
                {
                    string rtnFromClient = parameters.rtn;
                    var    rtnRequest    = new RTNRequest()
                    {
                        RTN = rtnFromClient
                    };
                    if (rtnRequest.isValidPost())
                    {
                        Guid idSucursal;

                        if (Guid.TryParse(parameters.sucursal, out idSucursal))
                        {
                            if (idSucursal != Guid.Empty)
                            {
                                var identidad = new Identidad(identidadRequest.identidad);
                                var empleo    = repositoryRead.getEmpleoMasRecienteBeneficiario(identidad);
                                if (empleo.Empresa.Id.Rtn == rtnRequest.RTN)
                                {
                                    if (empleo.Sucursal.Id == idSucursal)
                                    {
                                        var fichaEmpleo        = getEmpleoRequest(empleo);
                                        var fichaEmpleoString  = serializerJson.toJson(fichaEmpleo);
                                        var respestaEncriptada = encryptRequestProvider(token).encryptString(fichaEmpleoString);
                                        return(respestaEncriptada);
                                    }
                                }
                            }
                        }
                    }
                }
                return(new Response()
                       .WithStatusCode(HttpStatusCode.BadRequest));
            };
        }
Example #28
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBoxMail.Text.Trim().Equals("INCONSISTENTE"))
            {
                MessageBox.Show("Corrija el tipo y numero de documento y el Mail.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //ACTUALIZAR EL CLIENTE
            RepositorioCliente repoCliente = new RepositorioCliente();

            //ESTOS VALORES SON LOS QUE CAMBIAN
            //STRINGS
            String nombre       = textBoxNombre.Text.Trim();
            String apellido     = textBoxApellido.Text.Trim();
            String nroDoc       = textBoxNroDoc.Text.Trim();
            String mail         = textBoxMail.Text.Trim();
            String telefono     = textBoxTelefono.Text.Trim();
            String calle        = textBoxCalle.Text.Trim();
            String localidad    = textBoxLocalidad.Text.Trim();
            String pais         = textBoxPaisOrigen.Text.Trim();
            String nacionalidad = textBoxNacionalidad.Text.Trim();
            String depto        = textBoxDepto.Text.Trim();

            //NUMEROS
            int nroCalle = 0;

            if (textBoxNroCalle.Text != "")
            {
                nroCalle = int.Parse(textBoxNroCalle.Text);
            }
            int nroPiso = 0;

            if (textBoxPiso.Text != "")
            {
                nroPiso = int.Parse(textBoxPiso.Text);
            }

            //OTROS
            String tipoDoc = "";

            if (comboBoxTipoDoc.SelectedItem != null)
            {
                tipoDoc = (String)comboBoxTipoDoc.SelectedItem;
            }
            Boolean  activo          = checkBoxActivo.Checked;
            DateTime fechaNacimiento = dateTime.Value;

            //VALORES QUE NO CAMBIAN
            String         tipoIdentidad = "Cliente";
            int            idDir         = this.cliente.getIdentidad().getDireccion().getIdDireccion();
            int            idIdentidad   = this.cliente.getIdentidad().getIdIdentidad();
            int            idCliente     = this.cliente.getIdCliente();
            List <Reserva> reservas      = this.cliente.getReservas();
            Boolean        inconsistente = this.cliente.getInconsistente();

            Direccion adress        = new Direccion(idDir, pais, localidad, calle, nroCalle, nroPiso, depto);
            Identidad identidad     = new Identidad(idIdentidad, tipoIdentidad, nombre, apellido, tipoDoc, nroDoc, mail, fechaNacimiento, nacionalidad, telefono, adress);
            Cliente   updatedClient = new Cliente(idCliente, identidad, activo, reservas, inconsistente);

            if (this.validoInput(this))
            {
                try
                {
                    //SI EL CLIENTE ORIGINAL ESTABA INCONSISTENTE
                    if (cliente.getInconsistente())
                    {
                        repoCliente.limpioInconsistencia(updatedClient);
                        //LUEGO ACTUALIZO EL CLIENTE
                        repoCliente.updateAutoritativo(updatedClient);
                    }
                    else
                    {
                        //SI ES UN UPDATE NORMAL
                        repoCliente.update(updatedClient);
                    }

                    MessageBox.Show("Cliente actualizado con éxito", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    //ME TRAIGO EL USUARIO ACTUALIZADO
                    this.cliente = repoCliente.getById(cliente.getIdCliente());
                    this.resetearDatos();
                }
                //catch (NoExisteIDException exc)
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Verifique haber ingresado todos los datos necesarios para actualizar el Cliente", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            //GENERAR ALTA (no pido el estado ya que va como activo al momento de crearlo)

            //traigo los valores
            String   nacionalidad    = textBoxNacionalidad.Text.Trim();
            String   nombre          = textBoxNombre.Text.Trim();
            String   apellido        = textBoxApellido.Text.Trim();
            String   nroDoc          = textBoxNroDoc.Text.Trim();
            String   mail            = textBoxMail.Text.Trim();
            String   telefono        = textBoxTelefono.Text.Trim();
            String   calle           = textBoxCalle.Text.Trim();
            String   localidad       = textBoxLocalidad.Text.Trim();
            String   paisOrigen      = textBoxPaisOrigen.Text.Trim();
            DateTime fechaNacimiento = dateTime.Value;
            int      nroCalle        = 0;

            if (textBoxNroCalle.Text != "")
            {
                nroCalle = int.Parse(textBoxNroCalle.Text);
            }
            int nroPiso = 0;

            if (textBoxPiso.Text != "")
            {
                nroPiso = int.Parse(textBoxPiso.Text);
            }

            String         depto         = textBoxDepto.Text.Trim();
            String         tipoDoc       = "";
            String         tipoIdentidad = "Cliente";
            int            idDir         = 0;
            int            idIdentidad   = 0;
            int            idCliente     = 0;
            Boolean        activo        = true;
            List <Reserva> reservas      = new List <Reserva>();

            if (comboBoxTipoDoc.SelectedItem != null)
            {
                tipoDoc = (String)comboBoxTipoDoc.SelectedItem;
            }
            //armo direccion (id en 0)
            Direccion adress = new Direccion(idDir, paisOrigen, localidad,
                                             calle, nroCalle, nroPiso, depto);
            //armo la identidad con la direccion(id en 0)
            Identidad identidad = new Identidad(idIdentidad, tipoIdentidad, nombre, apellido, tipoDoc, nroDoc,
                                                mail, fechaNacimiento, nacionalidad, telefono, adress);
            // armo el cliente con la identidad (id en 0)
            Cliente cliente = new Cliente(idCliente, identidad, activo, reservas, false);
            //ahora si ya lo puedo crear
            RepositorioCliente repoCliente = new RepositorioCliente();

            if (this.validoInput(this))
            {
                try
                {
                    repoCliente.create(cliente);
                    MessageBox.Show("Cliente creado con éxito.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.limpiarPantalla();
                }
                //catch (ElementoYaExisteException exc)
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Verifique haber ingresado todos los datos necesarios para crear el Cliente.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            //ACTUALIZAR EL USUARIO
            RepositorioUsuario repoUser = new RepositorioUsuario();

            //ESTOS VALORES SON LOS QUE CAMBIAN
            //STRINGS
            String username     = textBoxUsername.Text.Trim();
            String nombre       = textBoxNombre.Text.Trim();
            String apellido     = textBoxApellido.Text.Trim();
            String nroDoc       = textBoxNroDoc.Text.Trim();
            String mail         = textBoxMail.Text.Trim();
            String telefono     = textBoxTelefono.Text.Trim();
            String calle        = textBoxCalle.Text.Trim();
            String localidad    = textBoxLocalidad.Text.Trim();
            String pais         = textBoxPais.Text.Trim();
            String nacionalidad = textBoxNacionalidad.Text.Trim();
            String depto        = textBoxDepto.Text.Trim();

            //NUMEROS
            int nroCalle = 0;

            if (textBoxNroCalle.Text != "")
            {
                nroCalle = int.Parse(textBoxNroCalle.Text);
            }
            int nroPiso = 0;

            if (textBoxPiso.Text != "")
            {
                nroPiso = int.Parse(textBoxPiso.Text);
            }

            //OTROS
            String tipoDoc = "";

            if (comboBoxTipoDoc.SelectedItem != null)
            {
                tipoDoc = (String)comboBoxTipoDoc.SelectedItem;
            }
            Boolean  activo          = checkBoxActivo.Checked;
            DateTime fechaNacimiento = dateTime.Value;

            //SI SE CAMBIA LA PASSWORD SE VUELVE A GENERAR
            //SINO SE MANTIENE LA MISMA
            if (this.password != null && this.password != "" && passwordChanged)
            {
                password = repoUser.EncriptarSHA256(this.password);
            }
            else
            {
                password = usuario.getPassword();
            }

            //VALORES QUE NO CAMBIAN
            String tipoIdentidad         = "Usuario";
            int    idDir                 = usuario.getIdentidad().getDireccion().getIdDireccion();
            int    idIdentidad           = usuario.getIdentidad().getIdIdentidad();
            int    idUsuario             = usuario.getIdUsuario();
            int    intentosFallidosLogin = usuario.getIntentosFallidosLogin();

            //traigo los roles elegidos
            List <Rol> roles = new List <Rol>();

            foreach (DataGridViewRow item in this.dataGridRoles.SelectedRows)
            {
                roles.Add(item.DataBoundItem as Rol);
            }
            //traigo los hoteles elegidos
            List <Hotel> hoteles = new List <Hotel>();

            foreach (DataGridViewRow item in this.dataGridHoteles.SelectedRows)
            {
                hoteles.Add(item.DataBoundItem as Hotel);
            }

            Direccion address   = new Direccion(idDir, pais, localidad, calle, nroCalle, nroPiso, depto);
            Identidad identidad = new Identidad(idIdentidad, tipoIdentidad, nombre, apellido, tipoDoc, nroDoc, mail, fechaNacimiento, nacionalidad, telefono, address);
            Usuario   user      = new Usuario(idUsuario, identidad, username, password, intentosFallidosLogin, activo, roles, hoteles);

            if (this.validoInput(this))
            {
                try
                {
                    repoUser.update(user);
                    MessageBox.Show("Usuario actualizado con éxito.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    //ME TRAIGO EL USUARIO ACTUALIZADO
                    this.usuario = repoUser.getById(usuario.getIdUsuario());
                    this.resetearDatos();
                }
                //catch (NoExisteIDException exc)
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Verifique haber ingresado todos los datos necesarios para actualizar el usuario, incluyendo los roles que el usuario desempeña y los hoteles donde el usuario trabaja.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }