public System.Collections.Generic.IList <ReciclaUAGenNHibernate.EN.ReciclaUA.PuntoReciclajeEN> BuscarPuntosCercanos(double p_latitud, double p_longitud, int p_limit) { /*PROTECTED REGION ID(ReciclaUAGenNHibernate.CEN.ReciclaUA_PuntoReciclaje_buscarPuntosCercanos) ENABLED START*/ PuntoReciclajeCP cp = new PuntoReciclajeCP(); return(cp.ObtenerPuntosCercanos(p_latitud, p_longitud, p_limit)); /*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> BuscarPuntosCercanosPorContenedor(double p_latitud, double p_longitud, ReciclaUAGenNHibernate.Enumerated.ReciclaUA.TipoContenedorEnum p_tipo, int p_limit) { /*PROTECTED REGION ID(ReciclaUAGenNHibernate.CEN.ReciclaUA_PuntoReciclaje_buscarPuntosCercanosPorContenedor) ENABLED START*/ PuntoReciclajeCP cp = new PuntoReciclajeCP(); PuntoReciclajeCEN cen = new PuntoReciclajeCEN(); ContenedorCEN cenc = new ContenedorCEN(); IList <PuntoReciclajeEN> cercanos = cp.ObtenerPuntosCercanos(p_latitud, p_longitud, -1); var query = cercanos.Where(punto => cenc.BuscarContenedoresPorPunto(punto.Id).Any(contenedor => contenedor.Tipo == p_tipo)); if (p_limit > 0) { query = query.Take(p_limit); } return(query.ToList()); /*PROTECTED REGION END*/ }
public void ValidarPunto(int p_oid) { /*PROTECTED REGION ID(ReciclaUAGenNHibernate.CEN.ReciclaUA_PuntoReciclaje_validarPunto) ENABLED START*/ // Write here your custom code... PuntoReciclajeCAD cad = new PuntoReciclajeCAD(); PuntoReciclajeEN en = cad.BuscarPorId(p_oid); if (en.EsValido != Enumerated.ReciclaUA.EstadoEnum.enProceso) { throw new ModelException("No se puede validar un punto de reciclaje que no est� en proceso de validaci�n"); } en.EsValido = Enumerated.ReciclaUA.EstadoEnum.verificado; cad.Modificar(en); PuntoReciclajeCP cp = new PuntoReciclajeCP(); cp.CrearAccionPunto(p_oid); /*PROTECTED REGION END*/ }
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); }