Ejemplo n.º 1
0
 public virtual Boolean removeDiscount(User session, ProductInStore p)
 {
     if (p == null || session == null)
     {
         return(false);
     }
     return(DiscountsManager.getInstance().removeDiscount(p.getProductInStoreId()));
 }
Ejemplo n.º 2
0
 public virtual Boolean addNewCoupon(User session, String couponId, ProductInStore p, int percentage, String dueDate)
 {
     if (session == null || couponId == null || p == null || percentage < 0 || dueDate == null || percentage <= 0)
     {
         return(false);
     }
     return(CouponsManager.getInstance().addNewCoupon(couponId, p.getProductInStoreId(), percentage, dueDate));
 }
Ejemplo n.º 3
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, ""));
 }
Ejemplo n.º 4
0
        public virtual int addProductInStore(User session, Store s, String productName, double price, int amount, string category)
        {
            if (productName == null || productName == "" ||
                productName[productName.Length - 1] == ' ')
            {
                return(-3);//-3 if illegal product name
            }
            if (session == null)
            {
                return(-1);// -1 if user Not Login
            }
            if (s == null)
            {
                return(-6);// -6 if illegal store id
            }
            if (amount <= 0)
            {
                return(-5);// -5 if illegal amount
            }
            if (price <= 0)
            {
                return(-7);// -7 if illegal price
            }
            //if(check if session is owner or manager with the right permission)
            Product p2 = ProductManager.getInstance().getProductByName(productName);

            if (p2 == null)
            {
                p2 = Product.addProduct(productName);
            }
            ProductManager pa  = ProductManager.getInstance();
            ProductInStore pis = pa.addProductInStore(p2, s, amount, price, category);

            if (pis != null)
            {
                return(pis.getProductInStoreId());
            }
            else
            {
                return(-8);
            }
        }
Ejemplo n.º 5
0
 public virtual int removeProductFromStore(User session, Store s, ProductInStore p)
 {
     if (session == null)
     {
         return(-1);//-1 if user Not Login
     }
     if (s == null)
     {
         return(-6);//-6 if illegal store id
     }
     if (p == null)
     {
         return(-8);//-8 if illegal product in store Id
     }
     if (ProductManager.getInstance().removeProductInStore(p.getProductInStoreId(), s.getStoreId()))
     {
         return(0);
     }
     return(-9);
 }
Ejemplo n.º 6
0
        private int checkAmountFulfillment(string country)
        {
            foreach (UserCart uc in products)
            {
                Sale           s          = SalesManager.getInstance().getSale(uc.getSaleId());
                ProductInStore theProduct = ProductManager.getInstance().getProductInStore(s.ProductInStoreId);
                LinkedList <PurchasePolicy> storePolicys          = PurchasePolicyManager.getInstance().getAllStorePolicys(theProduct.store.storeId);
                LinkedList <PurchasePolicy> countrysPolicys       = PurchasePolicyManager.getInstance().getAllCountryPolicys(country, theProduct.store.storeId);
                LinkedList <PurchasePolicy> categorysPolicys      = PurchasePolicyManager.getInstance().getAllCategoryPolicys(theProduct.Category, theProduct.store.storeId);
                LinkedList <PurchasePolicy> productPolicys        = PurchasePolicyManager.getInstance().getAllProductPolicys(theProduct.getProduct().name);
                LinkedList <PurchasePolicy> productInStorePolicys = PurchasePolicyManager.getInstance().getAllProductInStorePolicys(theProduct.getProductInStoreId());

                int currAmount = uc.getAmount();
                foreach (PurchasePolicy p in storePolicys)
                {
                    if (!p.NoLimit)
                    {
                        if (currAmount < p.MinAmount || currAmount > p.MaxAmount)
                        {
                            return(uc.getSaleId());
                        }
                    }
                }
                foreach (PurchasePolicy p in countrysPolicys)
                {
                    if (!p.NoLimit)
                    {
                        if (currAmount < p.MinAmount || currAmount > p.MaxAmount)
                        {
                            return(uc.getSaleId());
                        }
                    }
                }
                foreach (PurchasePolicy p in categorysPolicys)
                {
                    if (!p.NoLimit)
                    {
                        if (currAmount < p.MinAmount || currAmount > p.MaxAmount)
                        {
                            return(uc.getSaleId());
                        }
                    }
                }
                foreach (PurchasePolicy p in productPolicys)
                {
                    if (!p.NoLimit)
                    {
                        if (currAmount < p.MinAmount || currAmount > p.MaxAmount)
                        {
                            return(uc.getSaleId());
                        }
                    }
                }
                foreach (PurchasePolicy p in productInStorePolicys)
                {
                    if (!p.NoLimit)
                    {
                        if (currAmount < p.MinAmount || currAmount > p.MaxAmount)
                        {
                            return(uc.getSaleId());
                        }
                    }
                }
            }
            return(-1);
        }