示例#1
0
 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));
     }
 }
示例#2
0
        /// <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();
        }
示例#3
0
 private List <ShelfProduct> GetExistingShelfProducts(int row, int column)
 {
     return(ShelfProducts.Where(x => x.Row == row && x.Column == column).ToList());
 }
示例#4
0
 public void DeleteShelfProduct(ShelfProduct shelfProduct)
 {
     ShelfProducts.Remove(shelfProduct);
 }