예제 #1
0
        public OOB.Resultado.Lista <OOB.Inventario.Producto.Ficha> ProductoLista(OOB.Inventario.Producto.Filtro filtro)
        {
            var result = new OOB.Resultado.Lista <OOB.Inventario.Producto.Ficha>();

            var filtroDTO = new DTO.Inventario.Producto.Filtro();

            filtroDTO.cadena = filtro.cadena;
            filtroDTO.preferenciaBusqueda = (DTO.Inventario.Producto.Eumerados.enumPreferenciaBusqueda)filtro.preferenciaBusqueda;
            var r01 = MyData.ProductoLista(filtroDTO);

            if (r01.Result == DTO.Resultado.Enumerados.EnumResult.isError)
            {
                result.Mensaje = r01.Mensaje;
                result.Result  = OOB.Resultado.Enumerados.EnumResult.isError;
                return(result);
            }

            result.MyLista = new List <OOB.Inventario.Producto.Ficha>();
            if (r01.MyLista != null)
            {
                if (r01.MyLista.Count > 0)
                {
                    result.MyLista = r01.MyLista.Select(s =>
                    {
                        return(new OOB.Inventario.Producto.Ficha()
                        {
                            Auto = s.Auto,
                            CodigoPrd = s.CodigoPrd,
                            NombrePrd = s.NombrePrd,
                            Referencia = s.ReferenciaPrd,
                            IsActivo = s.IsActivo,
                        });
                    }).ToList();
                }
            }

            return(result);
        }
예제 #2
0
 public DTO.Resultado.Lista <DTO.Inventario.Producto.Resumen> ProductoLista(DTO.Inventario.Producto.Filtro filtro)
 {
     return(MyService.ProductoLista(filtro));
 }
        public DTO.Resultado.Lista <DTO.Inventario.Producto.Resumen> ProductoLista(DTO.Inventario.Producto.Filtro filtro)
        {
            var result = new DTO.Resultado.Lista <DTO.Inventario.Producto.Resumen>();

            try
            {
                using (var cnn = new leonuxEntities(_cn.ConnectionString))
                {
                    var q = cnn.productos.ToList();
                    if (filtro.cadena != "")
                    {
                        if (filtro.preferenciaBusqueda == DTO.Inventario.Producto.Eumerados.enumPreferenciaBusqueda.Codigo)
                        {
                            var cad = filtro.cadena.Trim().ToUpper();
                            if (cad.Substring(0, 1) == "*")
                            {
                                cad = cad.Substring(1);
                                q   = q.Where(w => w.codigo.Contains(cad)).ToList();
                            }
                            else
                            {
                                q = q.Where(w =>
                                {
                                    var r = w.codigo.Trim().ToUpper();
                                    if (r.Length >= cad.Length && r.Substring(0, cad.Length) == cad)
                                    {
                                        return(true);
                                    }
                                    else
                                    {
                                        return(false);
                                    }
                                }).ToList();
                            }
                        }
                        if (filtro.preferenciaBusqueda == DTO.Inventario.Producto.Eumerados.enumPreferenciaBusqueda.Nombre)
                        {
                            var cad = filtro.cadena.Trim().ToUpper();
                            if (cad.Substring(0, 1) == "*")
                            {
                                cad = cad.Substring(1);
                                q   = q.Where(w => w.nombre.Contains(cad)).ToList();
                            }
                            else
                            {
                                q = q.Where(w =>
                                {
                                    var r = w.nombre.Trim().ToUpper();
                                    if (r.Length >= cad.Length && r.Substring(0, cad.Length) == cad)
                                    {
                                        return(true);
                                    }
                                    else
                                    {
                                        return(false);
                                    }
                                }).ToList();
                            }
                        }
                        if (filtro.preferenciaBusqueda == DTO.Inventario.Producto.Eumerados.enumPreferenciaBusqueda.Referencia)
                        {
                            var cad = filtro.cadena.Trim().ToUpper();
                            if (cad.Substring(0, 1) == "*")
                            {
                                cad = cad.Substring(1);
                                q   = q.Where(w => w.referencia.Contains(cad)).ToList();
                            }
                            else
                            {
                                q = q.Where(w =>
                                {
                                    var r = w.referencia.Trim().ToUpper();
                                    if (r.Length >= cad.Length && r.Substring(0, cad.Length) == cad)
                                    {
                                        return(true);
                                    }
                                    else
                                    {
                                        return(false);
                                    }
                                }).ToList();
                            }
                        }
                    }

                    var list = new List <DTO.Inventario.Producto.Resumen>();
                    if (q != null)
                    {
                        if (q.Count() > 0)
                        {
                            result.MyLista = q.Select(s =>
                            {
                                var isActivo = s.estatus.Trim().ToUpper() == "ACTIVO" ? true : false;
                                var r        = new DTO.Inventario.Producto.Resumen()
                                {
                                    Auto           = s.auto,
                                    CodigoPrd      = s.codigo,
                                    NombrePrd      = s.nombre,
                                    DescripcionPrd = s.nombre,
                                    ReferenciaPrd  = s.referencia,
                                    IsActivo       = isActivo,
                                };
                                return(r);
                            }).ToList();
                        }
                        else
                        {
                            result.MyLista = list;
                        }
                    }
                    else
                    {
                        result.MyLista = list;
                    }
                }
            }
            catch (Exception e)
            {
                result.Mensaje = e.Message;
                result.Result  = DTO.Resultado.Enumerados.EnumResult.isError;
            }

            return(result);
        }