public async Task AddProductAsync(Product product) {
     List<Product> productList = await GetProductListFromFileAsync();
     int nextId = productList.Max(p => p.Id) + 1;
     product.Id = nextId;
     productList.Add(product);
     await SaveProductListToFileAsync(productList);
 }
 public void AddProduct(Product product)
 {
     int nextId = _productList.Max(p => p.Id) + 1;
     product.Id = nextId;
     _productList.Add(product);
     session["ProductList"] = _productList;
 }
 public async Task UpdateProductAsync(Product product) {
     List<Product> productList = await GetProductListFromFileAsync();
     Product targetProduct = productList.AsQueryable().FirstOrDefault(p => p.Id == product.Id);
     targetProduct.Name = product.Name;
     targetProduct.Category = product.Category;
     targetProduct.ListPrice = product.ListPrice;
     targetProduct.Description = product.Description;
     await SaveProductListToFileAsync(productList);
 }
 public void UpdateProduct(Product product)
 {
     Product targetProduct = _productList.FirstOrDefault(p => p.Id == product.Id);
     targetProduct.Name = product.Name;
     targetProduct.Category = product.Category;
     targetProduct.ListPrice = product.ListPrice;
     targetProduct.Description = product.Description;
     session["ProductList"] = _productList;
 }