Пример #1
0
        public Descuento(string json)
        {
            DataContractJsonSerializer serializador = new DataContractJsonSerializer(typeof(Descuento));
            MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(json));
            Descuento    des    = (Descuento)serializador.ReadObject(stream);

            this.IdDescuento    = des.IdDescuento;
            this.MinPuntos      = des.MinPuntos;
            this.MaxPuntos      = des.MaxPuntos;
            this.FechaCaducidad = des.FechaCaducidad;
            this.Porcentaje     = des.Porcentaje;
            this.Tope           = des.Tope;
        }
Пример #2
0
        public string traerCupones(string json)
        {
            DataContractJsonSerializer serializador = new DataContractJsonSerializer(typeof(FilterParameter));
            MemoryStream    stream = new MemoryStream(Encoding.UTF8.GetBytes(json));
            FilterParameter f      = (FilterParameter)serializador.ReadObject(stream);

            Core.DALC.QueOfrecesEntities ctx = new Core.DALC.QueOfrecesEntities();

            int          IdUsuario = int.Parse(f.parameter);
            var          result    = from a in ctx.CUPON where a.USUARIO_ID.Equals(IdUsuario) select new { a };
            List <Cupon> cupones   = new List <Cupon>();

            foreach (var item in result)
            {
                Cupon c = new Cupon();
                c.Codigo = item.a.CODIGO;

                c.fc = item.a.FECHA_HASTA.Value.ToShortDateString();
                var       descuento = from a in ctx.DESCUENTO where a.ID_DESCUENTO.Equals(item.a.DESCUENTO_ID) select new { a };
                Descuento d         = new Descuento();



                var r = from a in ctx.CATEGORIA_OFERTA join tempo in ctx.DESCUENTO_HAS_RUBRO on a.ID_CATEGORIA_OFERTA equals tempo.RUBRO_ID where tempo.DESCUENTO_ID == item.a.DESCUENTO_ID select new { a };
                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.Porcentaje = (int)ctx.DESCUENTO.Find(item.a.DESCUENTO_ID).PORCENTAJE;
                d.MinPuntos  = (int)ctx.DESCUENTO.Find(item.a.DESCUENTO_ID).MIN_PUNTOS;
                d.Tope       = (int)ctx.DESCUENTO.Find(item.a.DESCUENTO_ID).TOPE;
                c.Descuento  = d;
                cupones.Add(c);
            }
            string s = SerializarCupones(cupones);

            return(SerializarCupones(cupones));
        }