Exemplo n.º 1
0
        public List <int> GetCarrito()
        {
            List <int> libros = new List <int>();

            if (this.MemoryCache.Get("Libros") != null)
            {
                libros = ToolkitService.DeserializeJsonObject <List <int> >
                             (this.MemoryCache.Get("Libros").ToString());
            }
            return(libros);
        }
Exemplo n.º 2
0
        public List <int> QuitarLibro(int idLibro)
        {
            List <int> libros = new List <int>();

            if (this.MemoryCache.Get("Libros") != null)
            {
                libros = ToolkitService.DeserializeJsonObject <List <int> >
                             (this.MemoryCache.Get("Libros").ToString());
            }
            libros.RemoveAll(x => x == idLibro);
            httpContext.HttpContext.Session.SetInt32("carrito", libros.Count);
            this.MemoryCache.Set("Libros", ToolkitService.SerializeJsonObject(libros));
            return(libros);
        }
Exemplo n.º 3
0
        public void GuardarLibroCarrito(int idLibro)
        {
            List <int> libros  = new List <int>();
            int        carrito = 0;

            if (this.MemoryCache.Get("Libros") != null)
            {
                libros = ToolkitService.DeserializeJsonObject <List <int> >
                             (this.MemoryCache.Get("Libros").ToString());
            }
            libros.Add(idLibro);
            carrito += libros.Count;
            httpContext.HttpContext.Session.SetInt32("carrito", carrito);
            this.MemoryCache.Set("Libros", ToolkitService.SerializeJsonObject(libros));
        }