コード例 #1
0
        private void GetReceipts()
        {
            Receipts = _jsonHandler.GetRecords <ReceiptRecords>(_receiptFile);
            if (Receipts == null)
            {
                Receipts = new ReceiptRecords()
                {
                    ReceiptCurrentId = 0,
                    ReceiptList      = new List <Receipt>()
                };

                _jsonHandler.SaveRecords(_receiptFile, Receipts);
            }
        }
コード例 #2
0
        private void ReinitializeRepository()
#endif
        {
            Products = new ProductRecords
            {
                ProductList = new List <Product>
                {
                    new Product {
                        Id = 1, Name = "banana", Category = Category.Grocery, Description = "Banana from Mexico", Price = 1.67m
                    },
                    new Product {
                        Id = 2, Name = "apple", Category = Category.Grocery, Description = "Apple from China", Price = 2.67m
                    },
                    new Product {
                        Id = 3, Name = "Television", Category = Category.Electronic, Description = "Sony 65\"", Price = 1600.59m
                    }
                },
                ProductCurrentId = 3
            };

            Stocks = new List <ProductItem>
            {
                new ProductItem {
                    ProductId = 1, Count = 100
                },
                new ProductItem {
                    ProductId = 2, Count = 200
                },
                new ProductItem {
                    ProductId = 3, Count = 300
                },
            };

            Receipts = new ReceiptRecords()
            {
                ReceiptCurrentId = 0,
                ReceiptList      = new List <Receipt>()
            };

            _jsonHandler.SaveRecords(_productFile, Products);

            _jsonHandler.SaveRecords(_stockFile, Stocks);

            _jsonHandler.SaveRecords(_receiptFile, Receipts);
        }