예제 #1
0
        public string traerDescuentos()
        {
            Core.DALC.QueOfrecesEntities ctx = new Core.DALC.QueOfrecesEntities();
            var result = from a in ctx.DESCUENTO select new { a };

            List <Descuento> descLista = new List <Descuento>();

            foreach (var item in result)
            {
                //var r = from a in ctx.DESCUENTO_HAS_RUBRO where a.DESCUENTO_ID.Equals(item.a.ID_DESCUENTO) join c in ctx.CATEGORIA_OFERTA on a.RUBRO_ID equals c.ID_CATEGORIA_OFERTA select new { a , c };
                var       r = from a in ctx.CATEGORIA_OFERTA join c in ctx.DESCUENTO_HAS_RUBRO on a.ID_CATEGORIA_OFERTA equals c.RUBRO_ID where c.DESCUENTO_ID == item.a.ID_DESCUENTO select new { a };
                Descuento d = new Negocio.Descuento();

                List <CategoriaOferta> cat = new List <CategoriaOferta>();
                foreach (var itemc in r)
                {
                    CategoriaOferta ce = new CategoriaOferta();
                    ce.IdCategoria = (int)itemc.a.ID_CATEGORIA_OFERTA;
                    ce.Nombre      = itemc.a.NOMBRE;
                    cat.Add(ce);
                }
                d.Categorias  = cat;
                d.IdDescuento = (int)item.a.ID_DESCUENTO;
                d.MinPuntos   = (int)item.a.MIN_PUNTOS;
                d.MaxPuntos   = (int)item.a.MAX_PUNTOS;
                d.Porcentaje  = (int)item.a.PORCENTAJE;
                d.Tope        = (int)item.a.TOPE;
                descLista.Add(d);
            }

            return(SerializarDescuento(descLista));
        }
 public bool EliminarDesc(string json)
 {
     Negocio.Descuento desc = new Negocio.Descuento(json);
     return(desc.EliminarDescuento());
 }
 public bool CrearDesc(string json)
 {
     Negocio.Descuento desc = new Negocio.Descuento(json);
     return(desc.CrearDescuento());
 }
 public bool ActualizarDesc(string json)
 {
     Negocio.Descuento desc = new Negocio.Descuento(json);
     return(desc.ActualizarDescuento());
 }