public HttpResponseMessage DescartarPunto(int p_oid)
        {
            // CAD, CEN, returnValue
            PuntoReciclajeRESTCAD puntoReciclajeRESTCAD = null;
            PuntoReciclajeCEN     puntoReciclajeCEN     = null;

            try
            {
                SessionInitializeTransaction();
                string token = "";
                if (Request.Headers.Authorization != null)
                {
                    token = Request.Headers.Authorization.ToString();
                }
                int id = new UsuarioCEN().CheckToken(token);



                puntoReciclajeRESTCAD = new PuntoReciclajeRESTCAD(session);
                puntoReciclajeCEN     = new PuntoReciclajeCEN(puntoReciclajeRESTCAD);


                // Operation
                puntoReciclajeCEN.DescartarPunto(p_oid);
                SessionCommit();
            }

            catch (Exception e)
            {
                SessionRollBack();

                if (e.GetType() == typeof(HttpResponseException))
                {
                    throw e;
                }
                else if (e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto"))
                {
                    throw new HttpResponseException(HttpStatusCode.Forbidden);
                }
                else if (e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.DataLayerException))
                {
                    throw new HttpResponseException(HttpStatusCode.BadRequest);
                }
                else
                {
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
            finally
            {
                SessionClose();
            }

            // Return 200 - OK
            return(this.Request.CreateResponse(HttpStatusCode.OK));
        }
        public void CrearAccionPunto(int p_oid)
        {
            /*PROTECTED REGION ID(ReciclaUAGenNHibernate.CP.ReciclaUA_PuntoReciclaje_crearAccionPunto) ENABLED START*/

            IPuntoReciclajeCAD puntoReciclajeCAD = null;
            PuntoReciclajeCEN  puntoReciclajeCEN = null;
            AccionWebCEN       accionWebCEN      = null;
            ITipoAccionCAD     tipoAccionCAD     = null;
            TipoAccionCEN      tipoAccionCEN     = null;
            TipoAccionEN       tipoAccion        = null;
            IUsuarioWebCAD     usuarioWebCAD     = null;
            UsuarioWebCEN      usuarioWebCEN     = null;
            PuntoReciclajeEN   punto             = null;


            try
            {
                SessionInitializeTransaction();
                puntoReciclajeCAD = new PuntoReciclajeCAD(session);
                puntoReciclajeCEN = new PuntoReciclajeCEN(puntoReciclajeCAD);
                tipoAccionCAD     = new TipoAccionCAD(session);
                tipoAccionCEN     = new TipoAccionCEN(tipoAccionCAD);
                usuarioWebCAD     = new UsuarioWebCAD(session);
                usuarioWebCEN     = new UsuarioWebCEN(usuarioWebCAD);
                accionWebCEN      = new AccionWebCEN();

                punto = puntoReciclajeCEN.BuscarPorId(p_oid);

                if (punto.Usuario != null && usuarioWebCEN.BuscarPorId(punto.Usuario.Id) != null)
                {
                    tipoAccion = tipoAccionCEN.BuscarTodos(0, -1).Where(t => t.Nombre.Equals("Punto")).FirstOrDefault();

                    if (tipoAccion == null)
                    {
                        var id = tipoAccionCEN.Crear(30, "Punto");
                        tipoAccion = tipoAccionCEN.BuscarPorId(id);
                    }
                    accionWebCEN.Crear(punto.Usuario.Id, tipoAccion.Id);
                }

                SessionCommit();
            }
            catch (Exception ex)
            {
                SessionRollBack();
                throw ex;
            }
            finally
            {
                SessionClose();
            }


            /*PROTECTED REGION END*/
        }
        public static PuntoReciclajeDTOA Convert(PuntoReciclajeEN en, NHibernate.ISession session = null)
        {
            PuntoReciclajeDTOA    dto = null;
            PuntoReciclajeRESTCAD puntoReciclajeRESTCAD = null;
            PuntoReciclajeCEN     puntoReciclajeCEN     = null;
            PuntoReciclajeCP      puntoReciclajeCP      = null;

            if (en != null)
            {
                dto = new PuntoReciclajeDTOA();
                puntoReciclajeRESTCAD = new PuntoReciclajeRESTCAD(session);
                puntoReciclajeCEN     = new PuntoReciclajeCEN(puntoReciclajeRESTCAD);
                puntoReciclajeCP      = new PuntoReciclajeCP(session);



                //
                // Attributes

                dto.Id = en.Id;

                dto.Latitud = en.Latitud;


                dto.Longitud = en.Longitud;


                dto.EsValido = en.EsValido;


                //
                // TravesalLink

                /* Rol: PuntoReciclaje o--> Contenedor */
                dto.Contenedores = null;
                List <ContenedorEN> Contenedores = puntoReciclajeRESTCAD.Contenedores(en.Id).ToList();
                if (Contenedores != null)
                {
                    dto.Contenedores = new List <ContenedorDTOA>();
                    foreach (ContenedorEN entry in Contenedores)
                    {
                        dto.Contenedores.Add(ContenedorAssembler.Convert(entry, session));
                    }
                }

                /* Rol: PuntoReciclaje o--> Estancia */
                dto.EstanciaPunto = EstanciaAssembler.Convert((EstanciaEN)en.Estancia, session);


                //
                // Service
            }

            return(dto);
        }
        public System.Collections.Generic.IList <ReciclaUAGenNHibernate.EN.ReciclaUA.PuntoReciclajeEN> ObtenerPuntosCercanos(double p_latitud, double p_longitud, int p_limit)
        {
            /*PROTECTED REGION ID(ReciclaUAGenNHibernate.CP.ReciclaUA_PuntoReciclaje_obtenerPuntosCercanos) ENABLED START*/

            IPuntoReciclajeCAD puntoReciclajeCAD = null;
            PuntoReciclajeCEN  puntoReciclajeCEN = null;

            System.Collections.Generic.IList <ReciclaUAGenNHibernate.EN.ReciclaUA.PuntoReciclajeEN> result = null;


            try
            {
                SessionInitializeTransaction();
                puntoReciclajeCAD = new PuntoReciclajeCAD(session);
                puntoReciclajeCEN = new PuntoReciclajeCEN(puntoReciclajeCAD);

                GeoCoordinateWrapper referencia = new GeoCoordinateWrapper(p_latitud, p_longitud);

                IList <Tuple <GeoCoordinateWrapper, PuntoReciclajeEN> > coordenadas = new List <Tuple <GeoCoordinateWrapper, PuntoReciclajeEN> >();

                foreach (PuntoReciclajeEN punto in puntoReciclajeCEN.BuscarPuntosValidados())
                {
                    Console.WriteLine(punto.Estancia.Edificio + " " + punto.Estancia.Planta);
                    coordenadas.Add(new Tuple <GeoCoordinateWrapper, PuntoReciclajeEN>(new GeoCoordinateWrapper(punto.Latitud, punto.Longitud), punto));
                }

                var query = coordenadas.OrderBy(tupla => tupla.Item1.GetDistanceTo(referencia)).Select(tupla => tupla.Item2);

                if (p_limit > 0)
                {
                    query = query.Take(p_limit);
                }

                result = query.ToList();


                SessionCommit();
            }
            catch (Exception ex)
            {
                SessionRollBack();
                throw ex;
            }
            finally
            {
                SessionClose();
            }
            return(result);


            /*PROTECTED REGION END*/
        }
        public void CrearPunto(int p_oid)
        {
            /*PROTECTED REGION ID(ReciclaUAGenNHibernate.CP.ReciclaUA_PuntoReciclaje_crearPunto) ENABLED START*/

            IPuntoReciclajeCAD puntoReciclajeCAD = null;
            PuntoReciclajeCEN  puntoReciclajeCEN = null;



            try
            {
                SessionInitializeTransaction();
                puntoReciclajeCAD = new PuntoReciclajeCAD(session);
                puntoReciclajeCEN = new  PuntoReciclajeCEN(puntoReciclajeCAD);



                // Write here your custom transaction ...

                throw new NotImplementedException("Method CrearPunto() not yet implemented.");



                SessionCommit();
            }
            catch (Exception ex)
            {
                SessionRollBack();
                throw ex;
            }
            finally
            {
                SessionClose();
            }


            /*PROTECTED REGION END*/
        }
Example #6
0
 public void GivenQuieroCrearUnPuntoNuevoConNumeroYPontuacionSpecifica()
 {
     puntoReciclajeCEN = new PuntoReciclajeCEN();
 }
Example #7
0
        public HttpResponseMessage BuscarPuntosCercanosPorContenedor(double p_latitud, double p_longitud, ReciclaUAGenNHibernate.Enumerated.ReciclaUA.TipoContenedorEnum p_tipo, int p_limit)
        {
            // CAD, CEN, returnValue
            PuntoReciclajeRESTCAD puntoReciclajeRESTCAD = null;
            PuntoReciclajeCEN     puntoReciclajeCEN     = null;

            System.Collections.Generic.List <PuntoReciclajeDTOA> returnValue = null;
            System.Collections.Generic.List <PuntoReciclajeEN>   en;

            try
            {
                SessionInitializeTransaction();
                string token = "";
                if (Request.Headers.Authorization != null)
                {
                    token = Request.Headers.Authorization.ToString();
                }
                int id = new UsuarioCEN().CheckToken(token);



                puntoReciclajeRESTCAD = new PuntoReciclajeRESTCAD(session);
                puntoReciclajeCEN     = new PuntoReciclajeCEN(puntoReciclajeRESTCAD);


                // Operation
                en = puntoReciclajeCEN.BuscarPuntosCercanosPorContenedor(p_latitud, p_longitud, p_tipo, p_limit).ToList();
                SessionCommit();

                // Convert return
                if (en != null)
                {
                    returnValue = new System.Collections.Generic.List <PuntoReciclajeDTOA>();
                    foreach (PuntoReciclajeEN entry in en)
                    {
                        returnValue.Add(PuntoReciclajeAssembler.Convert(entry, session));
                    }
                }
            }

            catch (Exception e)
            {
                SessionRollBack();

                if (e.GetType() == typeof(HttpResponseException))
                {
                    throw e;
                }
                else if (e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto"))
                {
                    throw new HttpResponseException(HttpStatusCode.Forbidden);
                }
                else if (e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.DataLayerException))
                {
                    throw new HttpResponseException(HttpStatusCode.BadRequest);
                }
                else
                {
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
            finally
            {
                SessionClose();
            }

            // Return 200 - OK
            return(this.Request.CreateResponse(HttpStatusCode.OK, returnValue));
        }
Example #8
0
        public HttpResponseMessage Modificar(int idPuntoReciclaje, [FromBody] PuntoReciclajeDTO dto)
        {
            // CAD, CEN, returnValue
            PuntoReciclajeRESTCAD puntoReciclajeRESTCAD = null;
            PuntoReciclajeCEN     puntoReciclajeCEN     = null;
            PuntoReciclajeDTOA    returnValue           = null;

            // HTTP response
            HttpResponseMessage response = null;
            string uri = null;

            try
            {
                SessionInitializeTransaction();
                string token = "";
                if (Request.Headers.Authorization != null)
                {
                    token = Request.Headers.Authorization.ToString();
                }
                int id = new UsuarioCEN().CheckToken(token);



                puntoReciclajeRESTCAD = new PuntoReciclajeRESTCAD(session);
                puntoReciclajeCEN     = new PuntoReciclajeCEN(puntoReciclajeRESTCAD);

                // Modify
                puntoReciclajeCEN.Modificar(idPuntoReciclaje,
                                            dto.Latitud
                                            ,
                                            dto.Longitud
                                            ,
                                            dto.EsValido
                                            );

                // Return modified object
                returnValue = PuntoReciclajeAssembler.Convert(puntoReciclajeRESTCAD.ReadOIDDefault(idPuntoReciclaje), session);

                SessionCommit();
            }

            catch (Exception e)
            {
                SessionRollBack();

                if (e.GetType() == typeof(HttpResponseException))
                {
                    throw e;
                }
                else if (e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto"))
                {
                    throw new HttpResponseException(HttpStatusCode.Forbidden);
                }
                else if (e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.DataLayerException))
                {
                    throw new HttpResponseException(HttpStatusCode.BadRequest);
                }
                else
                {
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
            finally
            {
                SessionClose();
            }

            // Return 404 - Not found
            if (returnValue == null)
            {
                return(this.Request.CreateResponse(HttpStatusCode.NotFound));
            }
            // Return 200 - OK
            else
            {
                response = this.Request.CreateResponse(HttpStatusCode.OK, returnValue);

                return(response);
            }
        }
Example #9
0
        public HttpResponseMessage Crear([FromBody] PuntoReciclajeDTO dto)
        {
            // CAD, CEN, returnValue, returnOID
            PuntoReciclajeRESTCAD puntoReciclajeRESTCAD = null;
            PuntoReciclajeCEN     puntoReciclajeCEN     = null;
            PuntoReciclajeDTOA    returnValue           = null;
            int returnOID = -1;

            // HTTP response
            HttpResponseMessage response = null;
            string uri = null;

            try
            {
                SessionInitializeTransaction();
                string token = "";
                if (Request.Headers.Authorization != null)
                {
                    token = Request.Headers.Authorization.ToString();
                }
                int id = new UsuarioCEN().CheckToken(token);



                puntoReciclajeRESTCAD = new PuntoReciclajeRESTCAD(session);
                puntoReciclajeCEN     = new PuntoReciclajeCEN(puntoReciclajeRESTCAD);

                // Create
                returnOID = puntoReciclajeCEN.Crear(
                    //Atributo Primitivo: p_latitud
                    dto.Latitud,                        //Atributo Primitivo: p_longitud
                    dto.Longitud,                       //Atributo OID: p_usuario
                    // attr.estaRelacionado: true
                    dto.Usuario_oid                     // association role

                    ,                                   //Atributo OID: p_estancia
                    // attr.estaRelacionado: true
                    dto.Estancia_oid                    // association role

                    );
                SessionCommit();

                // Convert return
                returnValue = PuntoReciclajeAssembler.Convert(puntoReciclajeRESTCAD.ReadOIDDefault(returnOID), session);
            }

            catch (Exception e)
            {
                SessionRollBack();

                if (e.GetType() == typeof(HttpResponseException))
                {
                    throw e;
                }
                else if (e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto"))
                {
                    throw new HttpResponseException(HttpStatusCode.Forbidden);
                }
                else if (e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.DataLayerException))
                {
                    throw new HttpResponseException(HttpStatusCode.BadRequest);
                }
                else
                {
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
            finally
            {
                SessionClose();
            }

            // Return 201 - Created
            response = this.Request.CreateResponse(HttpStatusCode.Created, returnValue);

            // Location Header

            /*
             * Dictionary<string, object> routeValues = new Dictionary<string, object>();
             *
             * // TODO: y rolPaths
             * routeValues.Add("id", returnOID);
             *
             * uri = Url.Link("GetOIDPuntoReciclaje", routeValues);
             * response.Headers.Location = new Uri(uri);
             */

            return(response);
        }
Example #10
0
        public HttpResponseMessage BuscarPuntoPorContenedor(int contenedor_id)
        {
            // CAD, CEN, EN, returnValue

            PuntoReciclajeRESTCAD puntoReciclajeRESTCAD = null;
            PuntoReciclajeCEN     puntoReciclajeCEN     = null;


            PuntoReciclajeEN en;

            PuntoReciclajeDTOA returnValue;

            try
            {
                SessionInitializeWithoutTransaction();
                string token = "";
                if (Request.Headers.Authorization != null)
                {
                    token = Request.Headers.Authorization.ToString();
                }
                int id = new UsuarioCEN().CheckToken(token);



                puntoReciclajeRESTCAD = new PuntoReciclajeRESTCAD(session);
                puntoReciclajeCEN     = new PuntoReciclajeCEN(puntoReciclajeRESTCAD);

                // CEN return



                en = puntoReciclajeCEN.BuscarPuntoPorContenedor(contenedor_id);



                // Convert return
                returnValue = PuntoReciclajeAssembler.Convert(en, session);
            }

            catch (Exception e)
            {
                if (e.GetType() == typeof(HttpResponseException))
                {
                    throw e;
                }
                else if (e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto"))
                {
                    throw new HttpResponseException(HttpStatusCode.Forbidden);
                }
                else if (e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.DataLayerException))
                {
                    throw new HttpResponseException(HttpStatusCode.BadRequest);
                }
                else
                {
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
            finally
            {
                SessionClose();
            }

            // Return 204 - Empty
            if (returnValue == null)
            {
                return(this.Request.CreateResponse(HttpStatusCode.NoContent));
            }
            // Return 200 - OK
            else
            {
                return(this.Request.CreateResponse(HttpStatusCode.OK, returnValue));
            }
        }
Example #11
0
        public HttpResponseMessage BuscarPuntosPorPlanta(int?id_edificio, int?num_planta)
        {
            // CAD, CEN, EN, returnValue

            PuntoReciclajeRESTCAD puntoReciclajeRESTCAD = null;
            PuntoReciclajeCEN     puntoReciclajeCEN     = null;


            System.Collections.Generic.List <PuntoReciclajeEN> en;

            System.Collections.Generic.List <PuntoReciclajeDTOA> returnValue = null;

            try
            {
                SessionInitializeWithoutTransaction();
                string token = "";
                if (Request.Headers.Authorization != null)
                {
                    token = Request.Headers.Authorization.ToString();
                }
                int id = new UsuarioCEN().CheckToken(token);



                puntoReciclajeRESTCAD = new PuntoReciclajeRESTCAD(session);
                puntoReciclajeCEN     = new PuntoReciclajeCEN(puntoReciclajeRESTCAD);

                // CEN return



                en = puntoReciclajeCEN.BuscarPuntosPorPlanta(id_edificio, num_planta).ToList();



                // Convert return
                if (en != null)
                {
                    returnValue = new System.Collections.Generic.List <PuntoReciclajeDTOA>();
                    foreach (PuntoReciclajeEN entry in en)
                    {
                        returnValue.Add(PuntoReciclajeAssembler.Convert(entry, session));
                    }
                }
            }

            catch (Exception e)
            {
                if (e.GetType() == typeof(HttpResponseException))
                {
                    throw e;
                }
                else if (e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto"))
                {
                    throw new HttpResponseException(HttpStatusCode.Forbidden);
                }
                else if (e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.DataLayerException))
                {
                    throw new HttpResponseException(HttpStatusCode.BadRequest);
                }
                else
                {
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
            finally
            {
                SessionClose();
            }

            // Return 204 - Empty
            if (returnValue == null || returnValue.Count == 0)
            {
                return(this.Request.CreateResponse(HttpStatusCode.NoContent));
            }
            // Return 200 - OK
            else
            {
                return(this.Request.CreateResponse(HttpStatusCode.OK, returnValue));
            }
        }
Example #12
0
        public HttpResponseMessage CrearCP([FromBody] PuntoReciclajeDTO dto)
        {
            // CAD, CEN, returnValue, returnOID
            PuntoReciclajeRESTCAD puntoReciclajeRESTCAD = null;
            PuntoReciclajeCEN     puntoReciclajeCEN     = null;
            PuntoReciclajeDTOA    returnValue           = null;
            PuntoReciclajeCP      puntoCP = null;
            int returnOID = -1;

            // HTTP response
            HttpResponseMessage response = null;
            string uri = null;

            try
            {
                SessionInitializeTransaction();


                puntoReciclajeRESTCAD = new PuntoReciclajeRESTCAD(session);
                puntoReciclajeCEN     = new PuntoReciclajeCEN(puntoReciclajeRESTCAD);
                puntoCP = new PuntoReciclajeCP(session);

                // Create
                returnOID = puntoReciclajeCEN.Crear(dto.Latitud, dto.Longitud, dto.Usuario_oid, dto.Estancia_oid);
                puntoCP.CrearAccionPunto(returnOID);
                SessionCommit();

                // Convert return
                returnValue = PuntoReciclajeAssembler.Convert(puntoReciclajeRESTCAD.ReadOIDDefault(returnOID), session);
            }

            catch (Exception e)
            {
                SessionRollBack();

                if (e.GetType() == typeof(HttpResponseException))
                {
                    throw e;
                }
                else if (e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto"))
                {
                    throw new HttpResponseException(HttpStatusCode.Forbidden);
                }
                else if (e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.DataLayerException))
                {
                    throw new HttpResponseException(HttpStatusCode.BadRequest);
                }
                else
                {
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
            finally
            {
                SessionClose();
            }

            // Return 201 - Created
            response = this.Request.CreateResponse(HttpStatusCode.Created, returnValue);

            return(response);
        }
Example #13
0
        public static void InitializeData()
        {
            /*PROTECTED REGION ID(initializeDataMethod) ENABLED START*/

            try
            {
                Random random = new Random();

                /** TIPOS DE ACCION **/
                Console.WriteLine("Tipos de acción...");

                TipoAccionCEN tipoAccionCEN = new TipoAccionCEN();
                var           idTipo1       = tipoAccionCEN.Crear(10, "Duda");
                var           idTipo2       = tipoAccionCEN.Crear(5, "Respuesta");
                tipoAccionCEN.Crear(10, "Item");
                tipoAccionCEN.Crear(30, "Punto");
                tipoAccionCEN.Crear(10, "Material");

                /** USUARIOS **/
                Console.WriteLine("Usuarios...");

                IList <int>             ids_usuarios = new List <int>();
                UsuarioAdministradorCEN adminCEN     = new UsuarioAdministradorCEN();
                // var idAdminFer = adminCEN.Crear("Fernando", "de la Calle Rodríguez", "*****@*****.**", "fdlc4");
                // var idAdminAddel = adminCEN.Crear ("Addel Arnaldo", "Goya Jorge", "*****@*****.**", "aagj2");
                var id_admin = adminCEN.Crear("admin", "admin", "*****@*****.**", "admin");

                UsuarioWebCEN usuCEN = new UsuarioWebCEN();
                // ids_usuarios.Add(usuCEN.Crear ("Angela Sofia", "Sbrizzi Quilotte", "*****@*****.**", "assq1"));
                // ids_usuarios.Add(usuCEN.Crear ("José Antonio", "Agulló García", "*****@*****.**", "jaag14"));
                // ids_usuarios.Add(usuCEN.Crear ("mohamed", "walid Nebili", "*****@*****.**", "mwn1"));
                // ids_usuarios.Add(usuCEN.Crear("Fernando", "de la Calle Rodríguez", "*****@*****.**", "fdlc4"));
                ids_usuarios.Add(usuCEN.Crear("usu1", "usu1", "*****@*****.**", "usu1"));
                ids_usuarios.Add(usuCEN.Crear("usu2", "usu2", "*****@*****.**", "usu2"));

                /** NOTAS INFORMATIVAS **/
                Console.WriteLine("Notas informativas...");

                var lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque dui diam, tempus ac velit placerat, venenatis volutpat velit. Nam eget turpis nisi. Curabitur lectus arcu, vestibulum vitae interdum a, feugiat non neque. Sed velit ligula, tincidunt nec fringilla at, interdum eu nunc. Proin quis viverra nibh. Ut nec risus sem. Aenean enim libero, varius sit amet sem at, luctus semper dui. Donec feugiat ultricies quam, nec consequat dolor rutrum non. Ut sed massa nec nisi tincidunt dapibus id nec justo. Nunc vel enim id felis lacinia faucibus. Praesent molestie, nulla eleifend accumsan rhoncus, orci sem posuere mauris, id sollicitudin arcu eros eu leo. In quis lorem nec erat ornare suscipit in a felis. Cras porttitor lacus pretium, varius arcu at, sollicitudin erat. Nam aliquet accumsan metus et tincidunt. Nam et laoreet lectus, ut scelerisque elit. Phasellus vel enim ut dolor iaculis suscipit.";
                NotaInformativaCEN notaCEN = new NotaInformativaCEN();

                for (int i = 0; i < 10; i++)
                {
                    var id_nota = notaCEN.Crear(id_admin, "Nota informativa " + (i + 1), lorem);
                }

                /* DUDA */
                Console.WriteLine("Duda...");

                DudaCEN duda = new DudaCEN();
                Tuple <TemaEnum, string>[] temas = new Tuple <TemaEnum, string> [3];
                temas [0] = new Tuple <TemaEnum, string>(TemaEnum.anecdota, "Anécdota");
                temas [1] = new Tuple <TemaEnum, string>(TemaEnum.cuestion, "Cuestión");
                temas [2] = new Tuple <TemaEnum, string>(TemaEnum.consejo, "Consejo");

                RespuestaCEN respuesta = new RespuestaCEN();

                foreach (var tema in temas)
                {
                    Console.WriteLine("  " + tema.Item2 + "...");
                    for (int i = 0; i < 5; i++)
                    {
                        var id_duda = duda.Crear(tema.Item2 + " " + (i + 1), lorem, ids_usuarios [random.Next(0, ids_usuarios.Count)], tema.Item1);
                        for (int j = 0; j < 5; j++)
                        {
                            respuesta.Crear(lorem.Substring(random.Next(0, lorem.Length / 2)), id_duda, ids_usuarios [random.Next(0, ids_usuarios.Count)]);
                        }
                    }
                }

                /* MATERIAL */
                Console.WriteLine("Materiales...");

                MaterialCEN materialCEN = new MaterialCEN();

                int id_vidrio   = materialCEN.Crear("Vidrio", TipoContenedorEnum.cristal, ids_usuarios [random.Next(0, ids_usuarios.Count)]);
                int id_alimento = materialCEN.Crear("Alimento", TipoContenedorEnum.organico, ids_usuarios [random.Next(0, ids_usuarios.Count)]);
                int id_carton   = materialCEN.Crear("Cartón", TipoContenedorEnum.papel, ids_usuarios [random.Next(0, ids_usuarios.Count)]);
                int id_plastico = materialCEN.Crear("Plástico", TipoContenedorEnum.plastico, ids_usuarios [random.Next(0, ids_usuarios.Count)]);
                int id_papel    = materialCEN.Crear("Papel", TipoContenedorEnum.papel, ids_usuarios [random.Next(0, ids_usuarios.Count)]);
                int id_cristal  = materialCEN.Crear("Cristal", TipoContenedorEnum.cristal, ids_usuarios [random.Next(0, ids_usuarios.Count)]);

                IList <int> ids_materiales = new List <int> {
                    id_vidrio,
                    id_alimento,
                    id_carton,
                    id_plastico,
                    id_papel,
                    id_cristal
                };

                foreach (int id in ids_materiales)
                {
                    materialCEN.ValidarMaterial(id);
                }

                materialCEN.Crear("Espejo", TipoContenedorEnum.cristal, ids_usuarios [random.Next(0, ids_usuarios.Count)]);
                materialCEN.Crear("Papel aluminio", TipoContenedorEnum.plastico, ids_usuarios [random.Next(0, ids_usuarios.Count)]);
                materialCEN.Crear("Excremento", TipoContenedorEnum.organico, ids_usuarios [random.Next(0, ids_usuarios.Count)]);
                materialCEN.Crear("Cartulina", TipoContenedorEnum.papel, ids_usuarios [random.Next(0, ids_usuarios.Count)]);

                /* ITEMS */
                Console.WriteLine("Ítems...");

                ItemCEN itemCEN   = new ItemCEN();
                int     id_item_1 = itemCEN.Crear("Botella", "Botella de agua de plastico", "https://folder.es/41611-large_default/caja-de-35-botellas-de-agua-nestle-aquarel-033l.jpg", ids_usuarios [random.Next(0, ids_usuarios.Count)], id_plastico);
                int     id_item_2 = itemCEN.Crear("Macarrones", "Restos de macarrones", "https://www.rebanando.com/uploads/media/maxresdefault-jpg-19.jpeg?1449350333", ids_usuarios [random.Next(0, ids_usuarios.Count)], id_alimento);
                int     id_item_3 = itemCEN.Crear("Caja", "Caja de cartón de televisión", "https://www.farodeoriente.com/wp-content/uploads/2020/04/TV-samsung-caja-740x416.jpg", ids_usuarios [random.Next(0, ids_usuarios.Count)], id_carton);
                int     id_item_4 = itemCEN.Crear("Botellín", "Botellín de cristal de cerveza", "https://cervezafresca.com/wp-content/uploads/2011/04/cruzcampo.jpg", ids_usuarios [random.Next(0, ids_usuarios.Count)], id_vidrio);
                // Console.WriteLine("Creados los items: " + id_item_1 + ", " + id_item_2 + ", " + id_item_3 + ", " + id_item_4 + ", ");

                IList <int> ids_items = new List <int> {
                    id_item_1, id_item_2, id_item_3, id_item_4
                };

                foreach (int id in ids_items)
                {
                    itemCEN.ValidarItem(id, random.Next(5, 20));
                }

                /* NIVELES */
                Console.WriteLine("Niveles...");

                NivelCEN nivelCEN = new NivelCEN();

                int id_nivel_1 = nivelCEN.Crear(1, 5);
                int id_nivel_2 = nivelCEN.Crear(2, 10);
                // Console.WriteLine("Creados los niveles: " + id_nivel_1 + ", " + id_nivel_2);

                IList <int> ItemsNivel1 = new List <int>();
                ItemsNivel1.Add(id_item_1);
                ItemsNivel1.Add(id_item_2);
                nivelCEN.AsignarItems(id_nivel_1, ItemsNivel1);

                IList <int> ItemsNivel2 = new List <int>();
                ItemsNivel2.Add(id_item_3);
                ItemsNivel2.Add(id_item_4);
                nivelCEN.AsignarItems(id_nivel_2, ItemsNivel2);

                /* ZONAS Y PUNTOS */
                Console.WriteLine("Zonas y puntos...");

                ContenedorCEN        contenedorCEN = new ContenedorCEN();
                TipoContenedorEnum[] contenedores  = new TipoContenedorEnum [4];
                contenedores [0] = TipoContenedorEnum.cristal;
                contenedores [1] = TipoContenedorEnum.organico;
                contenedores [2] = TipoContenedorEnum.papel;
                contenedores [3] = TipoContenedorEnum.plastico;

                EdificioCEN       edificioCEN = new EdificioCEN();
                PlantaCEN         plantaCEN   = new PlantaCEN();
                EstanciaCEN       estanciaCEN = new EstanciaCEN();
                PuntoReciclajeCEN puntoCEN    = new PuntoReciclajeCEN();

                /* SIGUA */
                string       path = @"..\..\resources\sigua_eps.json";
                StreamReader sr   = File.OpenText(path);
                //Console.WriteLine(sr.ReadToEnd().Trim());
                JArray aEdificios = JArray.Parse(sr.ReadToEnd().Trim());

                foreach (var itemEdificio in aEdificios.Children())
                {
                    var edificioProperties = itemEdificio.Children <JProperty>();

                    var id      = edificioProperties.FirstOrDefault(x => x.Name == "id");
                    var nombre  = edificioProperties.FirstOrDefault(x => x.Name == "nombre");
                    var plantas = edificioProperties.FirstOrDefault(x => x.Name == "plantas");

                    Console.WriteLine("Edificio: " + nombre + "...");

                    var id_edificio = Int32.Parse(id.Value.ToString());
                    id_edificio = edificioCEN.Crear(nombre.Value.ToString(), id_edificio);

                    foreach (var planta in plantas.Children().Children())
                    {
                        PlantaEnum plantaE;
                        JProperty  plantaProperties = (JProperty)planta;

                        if (plantaProperties.Name == "P1")
                        {
                            plantaE = PlantaEnum.P1;
                        }
                        else if (plantaProperties.Name == "P2")
                        {
                            plantaE = PlantaEnum.P2;
                        }
                        else if (plantaProperties.Name == "P3")
                        {
                            plantaE = PlantaEnum.P3;
                        }
                        else if (plantaProperties.Name == "P4")
                        {
                            plantaE = PlantaEnum.P4;
                        }
                        else if (plantaProperties.Name == "PS")
                        {
                            plantaE = PlantaEnum.PS;
                        }
                        else
                        {
                            plantaE = PlantaEnum.PB;
                        }

                        var id_planta = plantaCEN.Crear(plantaE, id_edificio);

                        foreach (var itemEstancia in planta.Children().Children())
                        {
                            var estanciaProperties = itemEstancia.Children <JProperty>();

                            var estancia_codigo = estanciaProperties.FirstOrDefault(x => x.Name == "codigo");
                            var estancia_lon    = estanciaProperties.FirstOrDefault(x => x.Name == "longitud");
                            var estancia_lat    = estanciaProperties.FirstOrDefault(x => x.Name == "latitud");
                            var estancia_nom    = estanciaProperties.FirstOrDefault(x => x.Name == "nombre");
                            var estancia_act    = estanciaProperties.FirstOrDefault(x => x.Name == "actividad");

                            if (estancia_act.Value.ToString() == "Aseos" || estancia_act.Value.ToString() == "Vestuarios" || estancia_act.Value.ToString() == "Pasillos" || estancia_act.Value.ToString() == "Aseo femenino" || estancia_act.Value.ToString() == "Aseo masculino" || estancia_act.Value.ToString() == "Jardines")
                            {
                                if (estanciaCEN.BuscarPorId(estancia_codigo.Value.ToString()) == null)
                                {
                                    double latitud, longitud;
                                    latitud  = double.Parse(estancia_lat.Value.ToString().Replace(',', '.'), CultureInfo.InvariantCulture);
                                    longitud = double.Parse(estancia_lon.Value.ToString().Replace(',', '.'), CultureInfo.InvariantCulture);

                                    var id_estancia = estanciaCEN.Crear(estancia_codigo.Value.ToString(), estancia_act.Value.ToString(), latitud, longitud, estancia_nom.Value.ToString(), id_edificio, id_planta);
                                    var id_punto    = puntoCEN.Crear(latitud, longitud, ids_usuarios [random.Next(0, ids_usuarios.Count)], id_estancia);
                                    puntoCEN.ValidarPunto(id_punto);

                                    foreach (TipoContenedorEnum c in contenedores)
                                    {
                                        if (random.Next(0, 100) > 50)
                                        {
                                            contenedorCEN.Crear(c, id_punto);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                /*PROTECTED REGION END*/
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.InnerException);
                throw ex;
            }
        }
 public void GivenNoHayUnPuntoDeUnContenedorEspecifica()
 {
     puntoCEN      = new PuntoReciclajeCEN();
     contenedorCEN = new ContenedorCEN();
 }
 public void GivenNoHayUnPuntoConUnIdEspecifico()
 {
     punto_id          = -1;
     puntoReciclajeCEN = new PuntoReciclajeCEN();
 }
 public static void InitializeData()
 {
     puntoReciclajeCEN = new PuntoReciclajeCEN();
     punto_id          = puntoReciclajeCEN.Crear(12, 12, -1, null);
 }