コード例 #1
0
        //TODO: GET REAL PRODUCT
        public Product GetProduct(string name)
        {
            string jsonContent = _azuerAzureJsonDataService.GetFileContent(@"products.json");
            var    products    = JsonConvert.DeserializeObject <List <Product> >(jsonContent) ?? new List <Product>();

            return(products.First(x => x.Name == name));
        }
コード例 #2
0
        private void SaveProduct(Product product)
        {
            AzureJsonDataService azuerAzureJsonDataService = new AzureJsonDataService();
            string jsonContent = azuerAzureJsonDataService.GetFileContent(@"products.json");

            List <Product> productList = JsonConvert.DeserializeObject <List <Product> >(jsonContent) ?? new List <Product>();

            productList.Add(product);
            var ser = JsonConvert.SerializeObject(productList);

            azuerAzureJsonDataService.UpdateFileContent(ser, @"products.json");
        }