Beispiel #1
0
        public List <RamosModels> BuscarRamos(int id, string Descripcion, string Pais)
        {
            try
            {
                string documento = "C:/Users/Marcs/source/repos/WcfExamen/WcfExamen/Documentos/Productos_LATAM.xml";

                if (!File.Exists(documento))
                {
                    return(null);
                }

                XElement           xElement = XElement.Load(documento);
                List <RamosModels> lsRamos  = new List <RamosModels>();
                RamosModels        newRamos = new RamosModels();

                var consulta =
                    (from oRamos in xElement.Elements("Ramo")
                     where (oRamos.Attribute("id").Value.ToString() == id.ToString() ||
                            oRamos.Attribute("Descripcion").Value.Equals(Descripcion)) &&
                     oRamos.Attribute("Pais").Value.Equals(Pais)
                     select oRamos).ToList();

                foreach (var elemento in consulta)
                {
                    newRamos = new RamosModels()
                    {
                        id          = Convert.ToInt32(elemento.Attribute("id").Value),
                        Descripcion = elemento.Attribute("Descripcion").Value
                    };

                    lsRamos.Add(newRamos);
                }
                return(lsRamos);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Beispiel #2
0
        public JsonResult buscar(RamosModels RamosModels)
        {
            try
            {
                string Pais = string.Empty;
                if (Session["Pais"] != null)
                {
                    Pais = Session["Pais"].ToString();
                }

                //List<RamosModels> lsRamos = new List<RamosModels>();

                RamosDao ramosDao = new RamosDao();
                var      lsRamos  = ramosDao.Buscar(RamosModels.id, RamosModels.Descripcion, Pais);

                return(Json(lsRamos, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                throw;
            }
        }