Exemple #1
0
        public enlaces Obtener(int id)
        {
            enlaces enlace = new enlaces();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    //para retornar solo de la tabla alumno
                    // alumno = ctx.Alumno.Where(x => x.id == id)
                    //                   .SingleOrDefault();
                    //para retornar la relacion

                    enlace = ctx.enlaces.Include("proveedores")
                             .Include("oficinas")
                             .Include("oficinas.ciudades")
                             .Include("oficinas.tipoOficina")
                             .Include("oficinas.ciudades.departamentos")
                             .Include("enlacesTipo")
                             .Include("enlacesTecnologia")
                             .Include("enlacesServicios")
                             .Include("enlacesInternet")
                             .Include(x => x.contratos)
                             .Where(x => x.enlaceID == id)
                             .SingleOrDefault();
                    enlace.contratos = enlace.contratos.OrderByDescending(x => x.contratoID).ToList();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(enlace);
        }
Exemple #2
0
        public ResponseModel ObtenerAjax(int id)
        {
            enlaces enlaceAjax = new enlaces();
            var     rm         = new ResponseModel();

            try
            {
                using (var ctx = new inventarioContext())
                {
                    // ctx.Configuration.LazyLoadingEnabled = false;
                    //ctx.Configuration.ProxyCreationEnabled = false;// para retornar Json
                    ctx.Configuration.ProxyCreationEnabled = false;


                    enlaceAjax = ctx.enlaces.Include("proveedores")
                                 .Include("oficinas")
                                 .Include("oficinas.ciudades")
                                 .Include("oficinas.tipoOficina")
                                 .Include("oficinas.ciudades.departamentos")
                                 .Include("enlacesTipo")      //aqui esta el problema
                                 .Include("enlacesTecnologia")
                                 .Include("enlacesServicios")
                                 .Include("enlacesInternet")
                                 .Include(x => x.contratos)
                                 .Where(x => x.enlaceID == id)

                                 .SingleOrDefault();


                    enlaceAjax.contratos = enlaceAjax.contratos.OrderByDescending(x => x.contratoID).ToList();
                }
                rm.response = true;
                rm.message  = "";
                /****SERIALIZAR A JSON CON JSON.NET*****/
                rm.result = JsonConvert.SerializeObject(enlaceAjax, Formatting.Indented,
                                                        new JsonSerializerSettings()
                {
                    ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
                }
                                                        );
                /****FIN SERIALIZAR A JSON CON JSON.NET*****/
            }
            catch (Exception)
            {
                throw;
            }

            return(rm);
            // return this.Json
        }