Esempio n. 1
0
        public Cart GetUserCart(int userId)
        {
            Directory.CreateDirectory(_cartsXmlPath);
            var userCartPath = $"{_cartsXmlPath + userId}.xml";

            if (!File.Exists(userCartPath))
            {
                throw new Exception(MessageResource.UnavailableUserCart);
            }
            return(XmlSerializerTool.DeserializeObjectList <Cart>(userCartPath));
        }
Esempio n. 2
0
        public IList <Product> GetAllProducts()
        {
            var products = XmlSerializerTool.DeserializeObjectList <ProductsCollection>(_productsXmlPath).Products;

            return(products.Where(x => x.Count > 0).ToList()); //return only available products that has stocks
        }