public void SetShelfProducts(List <int> productIds, int row, int position) { ShelfProducts.Clear(); foreach (var productId in productIds) { ShelfProducts.Add(new ShelfProduct(Id, productId, row, position)); } }
/// <summary> /// Generates the items that should be discounted and those that should be left on /// the shelfes, those that should get a discount and those that go into the Zero Waste Bags /// </summary> /// <param name="products">All products from the crate</param> /// <param name="config">Class containing all the configurations relevant to the set</param> public CategorizerLogic(List <Product> products, WasteBagConfiguration config) { this.products = products; this.config = config; expired = new List <Product>(); shelf = new ShelfProducts(); discounted = new DiscountedProducts(); ZWB_candidates = new ZeroWasteBag(); ///Not only shorthand, but if the date changes during run, the results will be consistent DateTime today = DateTime.Today; ///ON the INFERENCE model: obtain object foreach (Product product in products) { /// In reality, this should not happen. Added for future-proofing if (product.ExpiryDate <= today) ///INFERENCE: obtain all attributes -> obtain feature { expired.Add(product); ///INFERENCE: match Truth value => true; if false move to next clause } ///DISCOUNT: Expires tomorrow else if (product.ExpiryDate <= today.AddDays(1)) { discounted.Add(product); } ///SHELF: expires in 2 days, but has high facing or expires in more than 2 days else if (((product.ExpiryDate <= today.AddDays(2)) && (product.Facing >= 4)) || (product.ExpiryDate > today.AddDays(2))) { shelf.Add(product); } ///ZWB: Expires in 2 days but has low facing else if ((product.ExpiryDate <= today.AddDays(2)) && (product.Facing <= 4)) { ZWB_candidates.Add(product); } } ///Sorts the ZWB products into the 5(or otherwise set by parameter) bags ZWB_final = generateWasteBags(); foreach (var p in ZWB_candidates) { discounted.Add(p); } ZWB_candidates.Clear(); }
private List <ShelfProduct> GetExistingShelfProducts(int row, int column) { return(ShelfProducts.Where(x => x.Row == row && x.Column == column).ToList()); }
public void DeleteShelfProduct(ShelfProduct shelfProduct) { ShelfProducts.Remove(shelfProduct); }