Example #1
0
        public LinkedList <UserCart> getShoppingCartBeforeCheckout(User session)
        {
            if (!(session.getState() is Guest))
            {
                products = UserCartsManager.getInstance().getUserShoppingCart(session.getUserName());
            }

            updateRegularPricesForCart(); // set all the regular prices for the cart - before discount
            foreach (UserCart uc in products)
            {
                Sale sale = SalesManager.getInstance().getSale(uc.getSaleId());
                LinkedList <Discount> discounts = DiscountsManager.getInstance().getAllDiscountsById(sale.ProductInStoreId);
                uc.PriceAfterDiscount = uc.Price;
                foreach (Discount d in discounts)
                {
                    if (fulfillTypeOfSaleRestriction(sale.TypeOfSale, d))
                    {
                        double dis          = uc.PriceAfterDiscount * (d.Percentage / 100);
                        double updatedPrice = uc.PriceAfterDiscount - dis;
                        uc.PriceAfterDiscount = updatedPrice;
                    }
                }
            }
            return(products);
        }
Example #2
0
        private void checkAndUpdateDiscountsByPolicys(string country)
        {
            Boolean skip = false;

            foreach (UserCart uc in products)
            {
                Sale s = SalesManager.getInstance().getSale(uc.getSaleId());
                LinkedList <Discount> relevantDiscounts = DiscountsManager.getInstance().getAllDiscountsById(s.ProductInStoreId);
                uc.PriceAfterDiscount = uc.Price;
                LinkedList <PurchasePolicy> policys = PurchasePolicyManager.getInstance().getAllRelevantPolicysForProductInStore(s.ProductInStoreId, country);
                foreach (PurchasePolicy p in policys)
                {
                    if (p.NoDiscount)
                    {
                        skip = true;
                    }
                }
                if (skip)
                {
                    skip = false;
                    continue;
                }

                foreach (Discount d in relevantDiscounts)
                {
                    checkPolicysAndUpdatePrice(uc, d, country, s.TypeOfSale);
                }
            }
        }
Example #3
0
 public virtual Boolean removeDiscount(User session, ProductInStore p)
 {
     if (p == null || session == null)
     {
         return(false);
     }
     return(DiscountsManager.getInstance().removeDiscount(p.getProductInStoreId()));
 }
Example #4
0
 public virtual Boolean addDiscount(User session, ProductInStore p, int percentage, String dueDate)
 {
     if (session == null || p == null || percentage < 0 || percentage >= 100 || dueDate == null)
     {
         return(false);
     }
     return(DiscountsManager.getInstance().addNewDiscount(p.getProductInStoreId(), 1, "", percentage, dueDate, ""));
 }
Example #5
0
 public virtual int addDiscounts(User session, int storeId, List <int> productInStores, int type,
                                 int percentage, List <string> categorysOrProductsName, string dueDate, string restrictions)
 {
     if (session == null || percentage < 0 || percentage >= 100 || dueDate == null)
     {
         return(-1);
     }
     return(DiscountsManager.getInstance().addNewDiscounts(type, productInStores, categorysOrProductsName, percentage, dueDate, restrictions));
 }