public void Cleanup() { List <Product> products = db_product.FindProductByPriceHigher(999.0); foreach (Product product in products) { db_product.DeleteProduct(product.Id); } }
/// <summary> /// Finds a list of products by their price. /// </summary> /// <param name="price"></param> /// <param name="where"></param> /// <returns>List<Product></returns> public List <Product> FindByPrice(double price, string where) { List <Product> result; switch (where) { case "Equal": result = db_product.FindProductByPrice(price); break; case "Higher": result = db_product.FindProductByPriceHigher(price); break; case "Lower": result = db_product.FindProductByPriceLower(price); break; default: result = new List <Product>(); break; } return(result); }
public void Initialize() { int index = 0; int max_index = 100; db_user = DBCustomUser.GetInstance(); db_product = DB_Product.GetInstance(); db_userproduct = DB_UserProduct.GetInstance(); Product product; user = new CustomUser { Username = "******", Password = "******", Email = "ClassLibriry1 - Test UserProduct Database - User", Wallet = 5000.0, IsActive = true, LoggedIn = true }; db_user.CreateUser(user); while (index < max_index) { product = new Product { Name = "ClassLibriry1 - Test UserProduct Database - Product", Price = 50.0 + (double)index }; db_product.CreateProduct(product); index++; } products = db_product.FindProductByPriceHigher(25.0); }