public ProductArr Filter(int id, string adress, Catagory category) { ProductArr productArr = new ProductArr(); for (int i = 0; i < this.Count; i++) { //הצבת המוצר הנוכחי במשתנה עזר - מוצר Product product = (this[i] as Product); if ( //סינון לפי מזהה המוצר (id <= 0 || product.ID == id) //סינון לפי שם המוצר && product.Adress.StartsWith(adress) //סינון לפי קטגוריה && (category == null || category.ID == -1 || product.Catagory.ID == category.ID) ) { //המוצר ענה לדרישות החיפוש - הוספה שלו לאוסף המוחזר productArr.Add(product); if (id > 0) { break; } } } return(productArr); }
public ProductArr Filter(Client client) { ProductArr productArr = new ProductArr(); //לבדוק למה צריך פה פיל (לבדוק דרך הרפרנס)כ productArr.Fill(); ProductArr productArr1 = new ProductArr(); for (int i = 0; i < productArr.Count; i++) { //הצבת המוצר הנוכחי במשתנה עזר - מוצר Product product = (productArr[i] as Product); ClientArr clientArr = new ClientArr(); clientArr.Fill(); Client client1 = clientArr.ReturnClientWithID(product.Client); if ( //סינון לפי מזהה הקלוח client1.ID == client.ID ) { //המוצר ענה לדרישות החיפוש - הוספה שלו לאוסף המוחזר productArr1.Add(product); } } return(productArr1); }
public void Remove(ProductArr productArr) { //מסירה מהאוסף הנוכחי את האוסף המתקבל for (int i = 0; i < productArr.Count; i++) { this.Remove(productArr[i] as Product); } }
public ProductArr FilterForSales(City city) { ProductArr productArr = new ProductArr(); for (int i = 0; i < this.Count; i++) { if ((this[i] as Product).City.ID == city.ID && (this[i] as Product).IsSold == 1) { productArr.Add(this[i] as Product); } } return(productArr); }
public Product FilterWithID(int id) { ProductArr productArr = new ProductArr(); for (int i = 0; i < this.Count; i++) { Product product = (this[i] as Product); if (product.ID == id) { return(product); } } return(null); }
public ProductArr FilterByAdress(string adress) { ProductArr productArr = new ProductArr(); for (int i = 0; i < this.Count; i++) { //הצבת המוצר הנוכחי במשתנה עזר - מוצר Product product = (this[i] as Product); if ( //סינון לפי שם המוצר product.Adress.StartsWith(adress) ) { //המוצר ענה לדרישות החיפוש - הוספה שלו לאוסף המוחזר productArr.Add(product); break; } } return(productArr); }
public ProductArr Filter(string adress, int catagory, int priceFrom, int priceTill) { ProductArr productArr = new ProductArr(); if (priceFrom != 0 && priceTill != 0) { for (int i = 0; i < this.Count; i++) { //הצבת המוצר הנוכחי במשתנה עזר - מוצר Product product = (this[i] as Product); if ( //סינון לפי שם המוצר product.Adress.StartsWith(adress) && product.Catagory.ID == catagory && product.Price > priceFrom && product.Price < priceTill ) { //המוצר ענה לדרישות החיפוש - הוספה שלו לאוסף המוחזר productArr.Add(product); break; } } } if (priceFrom == 0 && priceTill != 0) { for (int i = 0; i < this.Count; i++) { //הצבת המוצר הנוכחי במשתנה עזר - מוצר Product product = (this[i] as Product); if ( //סינון לפי שם המוצר product.Adress.StartsWith(adress) && product.Catagory.ID == catagory && product.Price < priceTill ) { //המוצר ענה לדרישות החיפוש - הוספה שלו לאוסף המוחזר productArr.Add(product); break; } } } if (priceFrom != 0 && priceTill == 0) { for (int i = 0; i < this.Count; i++) { //הצבת המוצר הנוכחי במשתנה עזר - מוצר Product product = (this[i] as Product); if ( //סינון לפי שם המוצר product.Adress.StartsWith(adress) && product.Catagory.ID == catagory && product.Price > priceFrom ) { //המוצר ענה לדרישות החיפוש - הוספה שלו לאוסף המוחזר productArr.Add(product); break; } } } if (priceFrom == 0 && priceTill == 0) { for (int i = 0; i < this.Count; i++) { //הצבת המוצר הנוכחי במשתנה עזר - מוצר Product product = (this[i] as Product); if ( //סינון לפי שם המוצר product.Adress.StartsWith(adress) && product.Catagory.ID == catagory ) { //המוצר ענה לדרישות החיפוש - הוספה שלו לאוסף המוחזר productArr.Add(product); break; } } } return(productArr); }