namespace InventoryAccessLibrary
{
public class InventoryAccess : IInventory
{
#region IInventory Members
public Product[] GetProducts()
{
ProductsTableAdapter tableAdapter = new ProductsTableAdapter();
var query = from NorthwindDataSet.ProductsRow row in tableAdapter.GetData()
select new Product {
Name = row.ProductName,
UnitsInStock = row.UnitsInStock };
return query.ToArray();
}
public bool AddProduct(Product newProduct)
{
ProductsTableAdapter tableAdapter = new ProductsTableAdapter();
// Use default values and the valid SupplierId of 1
int rowsChanged = tableAdapter.Insert(
newProduct.Name, null, null, "1", null, null, null, null, false);
return rowsChanged == 1;
}
#endregion
}
}