Exemplo n.º 1
0
        public static List <Coupon> GetCoupons()
        {
            List <Coupon> coupons = new List <Coupon>();

            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            using (StreamReader r = new StreamReader("Integration/SampleData.json", Encoding.GetEncoding(1254)))
            {
                string          json        = r.ReadToEnd();
                SampleDataClass jsonContent = JsonConvert.DeserializeObject <SampleDataClass>(json);
                coupons.AddRange(jsonContent.AmountCoupons);
            }
            return(coupons);
        }
Exemplo n.º 2
0
        public static List <Product> GetProducts()
        {
            List <Product> products = new List <Product>();

            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            using (StreamReader r = new StreamReader("Integration/SampleData.json", Encoding.GetEncoding(1254)))
            {
                string          json        = r.ReadToEnd();
                SampleDataClass jsonContent = JsonConvert.DeserializeObject <SampleDataClass>(json);
                products = jsonContent.Products;
            }
            return(products);
        }
        public static List <Category> GetCategories()
        {
            List <Category> categories = new List <Category>();

            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            using (StreamReader r = new StreamReader("Integration/SampleData.json", Encoding.GetEncoding(1254)))
            {
                string          json        = r.ReadToEnd();
                SampleDataClass jsonContent = JsonConvert.DeserializeObject <SampleDataClass>(json);
                categories = jsonContent.Categories;
                categories.ForEach(category =>
                {
                    if (category.ParentCategoryId != 0)
                    {
                        category.ParentCategory = categories.FirstOrDefault(parentCategory => parentCategory.Id == category.ParentCategoryId);
                    }
                });
            }
            Categories = categories;
            return(categories);
        }