public IEnumerable <BePsCategory> Buscar(BePsCategory objeto, ref string mensaje, ref string tipo)
        {
            List <BePsCategory> lbePsCategory = null;

            try
            {
                using (MySqlConnection cn = new MySqlConnection(Conexion))
                {
                    if (cn.State == 0)
                    {
                        cn.Open();
                    }

                    string sp = "Sp_AppSelectCategory";

                    using (MySqlCommand cmd = new MySqlCommand(sp, cn))
                    {
                        cmd.CommandTimeout = 0;
                        cmd.CommandType    = CommandType.StoredProcedure;
                        MySqlDataReader dr = cmd.ExecuteReader(CommandBehavior.Default);

                        if (dr.HasRows)
                        {
                            lbePsCategory = new List <BePsCategory>();
                            int posCatRef = dr.GetOrdinal("category_value");
                            int posCatNam = dr.GetOrdinal("category_name");

                            BePsCategory obePsCategory;
                            while (dr.Read())
                            {
                                obePsCategory            = new BePsCategory();
                                obePsCategory.Referencia = dr.GetString(posCatRef);
                                obePsCategory.Nombre     = dr.GetString(posCatNam);
                                lbePsCategory.Add(obePsCategory);
                            }

                            dr.Close();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                mensaje = Configuration.SI_MSJ_DES_ERROR + "\n\n" + "Detalle de Error: " + e.Message;
                tipo    = Configuration.SI_MSJ_TIP_ERROR;
            }

            mensaje = Configuration.SI_MSJ_TIP_EXITO;
            tipo    = Configuration.SI_MSJ_TIP_EXITO;

            return(lbePsCategory);
        }
        public JsonResult BuscarPsCategory(string catnom)
        {
            psCategoryService = new PsCategoryService();
            ResponseViewModel res = new ResponseViewModel();

            string mensaje = "";
            string tipo    = "";

            try
            {
                BePsCategory cat = new BePsCategory();
                cat.Nombre = catnom;
                List <BePsCategory> lst = psCategoryService.Buscar(cat, ref mensaje, ref tipo).ToList();
                res.Tipo    = tipo;
                res.Mensaje = mensaje;
                res.Lista   = lst.OrderBy(x => x.Nombre);
            }
            catch (Exception e)
            {
                res.Tipo    = Configuration.SI_MSJ_TIP_ERROR;
                res.Mensaje = e.Message;
            }
            return(Json(res));
        }
Exemplo n.º 3
0
 public IEnumerable <BePsCategory> Buscar(BePsCategory objeto, ref string mensaje, ref string tipo)
 {
     return(psCategoryDAO.Buscar(objeto, ref mensaje, ref tipo));
 }