private OfertaCollections GenerarListadoDesactivo(List <DALC.OFERTA> listaDALC)
        {
            OfertaCollections lista = new OfertaCollections();

            foreach (var item in listaDALC)
            {
                if (item.ESTADO_OFERTA == "0")
                {
                    Oferta of = new Oferta();
                    of.IdOferta          = (int)item.ID_OFERTA;
                    of.ImagenOferta      = item.IMAGEN_OFERTA;
                    of.MinProductos      = (int)item.MIN_PRODUCTO;
                    of.MaxProductos      = (int)item.MAX_PRODUCTO;
                    of.EstadoOferta      = Convert.ToChar(item.ESTADO_OFERTA);
                    of.PrecioOferta      = (int)item.PRECIO_DESPUES;
                    of.PrecioAntes       = (int)item.PRECIO_ANTES;
                    of.FechaOferta       = item.FECHA_OFERTA;
                    of.IdSucursal        = (int)item.SUCURSALES_ID;
                    of.CategoriaIdOferta = (int)item.CATEGORIA_OFERTA_ID;
                    of.Nombre            = item.NOMBRE;
                    of.Descripcion       = item.DESCRIPCION;
                    of.Selec             = false;

                    lista.Add(of);
                }
            }
            return(lista);
        }
        private OfertaCollections GenerarListadoActivoWeb()
        {
            DALC.QueOfrecesEntities ctx = new DALC.QueOfrecesEntities();

            var listaDALC = from o in ctx.OFERTA
                            where o.ESTADO_OFERTA == "1"
                            select o;

            OfertaCollections lista = new OfertaCollections();

            foreach (var item in listaDALC)
            {
                Oferta of = new Oferta();
                of.IdOferta          = (int)item.ID_OFERTA;
                of.ImagenOferta      = item.IMAGEN_OFERTA;
                of.MinProductos      = (int)item.MIN_PRODUCTO;
                of.MaxProductos      = (int)item.MAX_PRODUCTO;
                of.EstadoOferta      = Convert.ToChar(item.ESTADO_OFERTA);
                of.PrecioOferta      = (int)item.PRECIO_DESPUES;
                of.PrecioAntes       = (int)item.PRECIO_ANTES;
                of.FechaOferta       = item.FECHA_OFERTA;
                of.IdSucursal        = (int)item.SUCURSALES_ID;
                of.CategoriaIdOferta = (int)item.CATEGORIA_OFERTA_ID;
                of.Nombre            = item.NOMBRE;
                of.Descripcion       = item.DESCRIPCION;
                of.Selec             = true;

                lista.Add(of);
            }
            return(lista);
        }
Exemplo n.º 3
0
        private async void btnBuscar_Click(object sender, RoutedEventArgs e)
        {
            ServiceReference1.Service1Client proxy = new ServiceReference1.Service1Client();
            string json = proxy.ReadAllOfertas(mainwindow.RetailActual.IdRetail);

            Core.Negocio.OfertaCollections collOf = new Core.Negocio.OfertaCollections(json);

            Core.Negocio.OfertaCollections collOfer = new Core.Negocio.OfertaCollections();

            if (txtBuscar.Text == "")
            {
                dataGridOferta.ItemsSource = collOf;
            }
            else
            {
                try
                {
                    foreach (var item in collOf)
                    {
                        if (txtBuscar.Text.Equals(item.Nombre))
                        {
                            collOfer.Add(item);
                        }
                    }

                    if (collOfer.Count == 0)
                    {
                        await this.ShowMessageAsync("Fallo", "No se encontro la oferta");
                    }
                    else
                    {
                        dataGridOferta.ItemsSource = collOfer;
                    }
                }
                catch (Exception)
                {
                    await this.ShowMessageAsync("Fallo", "No se encontro la oferta");
                }
            }
        }
        private OfertaCollections GenerarListado(int idRetail)
        {
            DALC.QueOfrecesEntities ctx = new DALC.QueOfrecesEntities();

            var listaDALC = from o in ctx.OFERTA
                            join s in ctx.SUCURSALES on o.SUCURSALES_ID equals s.ID_SUCURSAL
                            where s.RETAIL_ID == idRetail
                            select o;

            OfertaCollections lista = new OfertaCollections();

            foreach (var item in listaDALC)
            {
                Oferta of = new Oferta();
                of.IdOferta          = (int)item.ID_OFERTA;
                of.ImagenOferta      = item.IMAGEN_OFERTA;
                of.MinProductos      = (int)item.MIN_PRODUCTO;
                of.MaxProductos      = (int)item.MAX_PRODUCTO;
                of.EstadoOferta      = Convert.ToChar(item.ESTADO_OFERTA);
                of.PrecioOferta      = (int)item.PRECIO_DESPUES;
                of.PrecioAntes       = (int)item.PRECIO_ANTES;
                of.FechaOferta       = item.FECHA_OFERTA;
                of.IdSucursal        = (int)item.SUCURSALES_ID;
                of.CategoriaIdOferta = (int)item.CATEGORIA_OFERTA_ID;
                of.Nombre            = item.NOMBRE;
                of.Descripcion       = item.DESCRIPCION;
                if (of.EstadoOferta == '1')
                {
                    of.Selec = true;
                }
                else
                {
                    of.Selec = false;
                }

                lista.Add(of);
            }
            return(lista);
        }