Пример #1
0
        public void addDiscountWithManagerPermission()
        {
            ProductInStore pis    = ProductManager.getInstance().getProductInStore(ss.addProductInStore("cola", 150, 100, zahi, store.getStoreId(), "Drink"));
            int            saleId = ss.addSaleToStore(zahi, store.getStoreId(), pis.getProductInStoreId(), 1, 40, DateTime.Now.AddYears(1).ToString());

            ss.removeManagerPermission("addDiscount", store.getStoreId(), aviad.getUserName(), zahi);
            Assert.AreEqual(0, DiscountsManager.getInstance().getAllDiscounts().Count);
        }
 public void init()
 {
     WebServices.DAL.CleanDB cDB = new WebServices.DAL.CleanDB();
     cDB.emptyDB();
     DiscountsManager.restartInstance();
     discountsArchive = DiscountsManager.getInstance();
     discountsArchive.addNewDiscount(1, 1, "", 10, DateTime.Now.AddDays(10).ToString(), "");
     discountsArchive.addNewDiscount(2, 1, "", 20, DateTime.Now.AddDays(15).ToString(), "");
 }
Пример #3
0
 public void init()
 {
     WebServices.DAL.CleanDB cDB = new WebServices.DAL.CleanDB();
     cDB.emptyDB();
     ProductManager.restartInstance();
     DiscountsManager.restartInstance();
     productArchive   = ProductManager.getInstance();
     discountsArchive = DiscountsManager.getInstance();
     milk             = productArchive.addProduct("milk");
     store            = new Store(1, "halavi", new User("itamar", "123456"));
     milkInStore      = productArchive.addProductInStore(milk, store, 50, 200);
 }
Пример #4
0
        //not implemented
        // new Addition for version 2 - need to handle addDiscount function
        // type: 1 for discount on productsInStore, 2 for discount on category, 3 for discount on entire product (in product archive)
        public int addDiscounts(User session, int storeId, List <int> productInStores, int type,
                                int percentage, List <string> categorysOrProductsName, string dueDate, string restrictions)
        {
            if (type == 3)
            {
                return(DiscountsManager.getInstance().addNewDiscounts(type, productInStores, categorysOrProductsName, percentage, dueDate, restrictions));
            }
            Store     s  = StoreManagement.getInstance().getStore(storeId);
            StoreRole sR = StoreRole.getStoreRole(s, session);

            if (sR == null)
            {
                return(-1);
            }
            return(sR.addDiscounts(session, storeId, productInStores, type, percentage, categorysOrProductsName
                                   , dueDate, restrictions));
        }
Пример #5
0
 public void init()
 {
     //              ARCHIVE INIT
     WebServices.DAL.CleanDB cDB = new WebServices.DAL.CleanDB();
     cDB.emptyDB();
     PurchasePolicyManager.restartInstance();
     SalesManager.restartInstance();
     DiscountsManager.restartInstance();
     CouponsManager.restartInstance();
     StoreManagement.restartInstance();
     UserManager.restartInstance();
     ProductManager.restartInstance();
     UserCartsManager.restartInstance();
     purchasePolicyArchive = PurchasePolicyManager.getInstance();
     salesArchive          = SalesManager.getInstance();
     discountsArchive      = DiscountsManager.getInstance();
     couponsArchive        = CouponsManager.getInstance();
     productArchive        = ProductManager.getInstance();
     StoreManagement       = StoreManagement.getInstance();
     userArchive           = UserManager.getInstance();
     //              USERS INIT
     admin = new User("admin", "123456");
     admin.register("admin", "123456");
     admin.login("admin", "123456");
     storeOwner = new User("owner", "123456");
     storeOwner.register("owner", "123456");
     storeOwner.login("owner", "123456");
     itamar = new User("itamar", "123456");
     itamar.register("itamar", "123456");
     itamar.login("itamar", "123456");
     shay = new User("shay", "123456");
     shay.register("shay", "123456");
     shay.login("shay", "123456");
     //             PRODUCTS INIT
     cola   = productArchive.addProduct("cola");
     sprite = productArchive.addProduct("sprite");
     //             STORES AND PRODUCTS IN STORES
     store         = StoreManagement.addStore("samsung", storeOwner);
     colaInStore   = productArchive.addProductInStore(cola, store, 200, 500, "cola category");
     spriteInStore = productArchive.addProductInStore(sprite, store, 100, 200, "sprite category");
     //             SALES INIT
     colaRegularSale  = salesArchive.addSale(colaInStore.getProductInStoreId(), regularSale, 50, DateTime.Now.AddDays(10).ToString());
     spriteRaffleSale = salesArchive.addSale(spriteInStore.getProductInStoreId(), raffleSale, 3, DateTime.Now.AddDays(20).ToString());
 }
        public void init()
        {
            WebServices.DAL.CleanDB cDB = new WebServices.DAL.CleanDB();
            cDB.emptyDB();
            ProductManager.restartInstance();
            SalesManager.restartInstance();
            StoreManagement.restartInstance();
            UserManager.restartInstance();
            UserCartsManager.restartInstance();
            DiscountsManager.restartInstance();
            CouponsManager.restartInstance();
            RaffleSalesManager.restartInstance();
            pA        = ProductManager.getInstance();
            saleA     = SalesManager.getInstance();
            storeA    = StoreManagement.getInstance();
            userA     = UserManager.getInstance();
            userCartA = UserCartsManager.getInstance();
            discountA = DiscountsManager.getInstance();
            couponA   = CouponsManager.getInstance();
            raffleA   = RaffleSalesManager.getInstance();

            p1 = pA.addProduct("Milk");
            p2 = pA.addProduct("Bread");
            p3 = pA.addProduct("T.V");

            zahi  = new User("zahi", "123456");
            aviad = new User("aviad", "123456");
            aviad.register("aviad", "123456");
            zahi.register("zahi", "123456");

            store = storeA.addStore("zahi inc", zahi);

            pis1 = ProductManager.getInstance().addProductInStore(p1, store, 20, 10);
            pis2 = ProductManager.getInstance().addProductInStore(p2, store, 30, 15);
            pis3 = ProductManager.getInstance().addProductInStore(p3, store, 40, 50);

            sale1 = saleA.addSale(pis1.getProductInStoreId(), 1, 10, "1/5/2020");
            sale2 = saleA.addSale(pis2.getProductInStoreId(), 1, 10, "1/5/2020");
            sale3 = saleA.addSale(pis3.getProductInStoreId(), 3, 1, "1/5/2020");

            cart = new ShoppingCart();
        }