Ejemplo n.º 1
0
        public void editProductInStoreWithManagerPermission()
        {
            int            pisId = zahiOwner.addProductInStore(zahi, store, "cola2", 10, 4, "Drinks");
            ProductInStore pis   = ProductManager.getInstance().getProductInStore(pisId);

            Assert.AreEqual(2, store.getProductsInStore().Count);
            aviadManeger.editProductInStore(aviad, pis, 13, 4.5);
            Assert.AreEqual(10, pis.getPrice());
            Assert.AreEqual(4, pis.getAmount());
            zahiOwner.addManagerPermission(zahi, "editProductInStore", store, "aviad");
            aviadManeger.editProductInStore(aviad, pis, 13, 4.5);
            Assert.AreEqual(4.5, pis.getPrice());
            Assert.AreEqual(13, pis.getAmount());
        }
Ejemplo n.º 2
0
        //req 3.1 a

        /*
         * return:
         *           0 > on sucess return productInStoreId
         *          -1 if user Not Login
         *          -2 if Store Name already exist
         *          -3 if illegal product name
         *          -4 if don't have premition
         *          -5 if illegal amount
         *          -6 if illegal store id
         *          -7 if illegal price
         *
         */
        public int addProductInStore(String productName, Double price, int amount, User session, int sId, string category)
        {
            if (session == null || !session.getState().isLogedIn() || productName == null || category == null)
            {
                return(-1);//-1 if user Not Login
            }
            Store     s  = StoreManagement.getInstance().getStore(sId);
            StoreRole sR = StoreRole.getStoreRole(s, session);

            if (sR == null)
            {
                return(-4);//-4 if don't have premition
            }
            return(sR.addProductInStore(session, s, productName, price, amount, category));
        }
Ejemplo n.º 3
0
        public void init()
        {
            WebServices.DAL.CleanDB cDB = new WebServices.DAL.CleanDB();
            cDB.emptyDB();
            ProductManager.restartInstance();
            SalesManager.restartInstance();
            StoreManagement.restartInstance();
            UserManager.restartInstance();
            UserCartsManager.restartInstance();
            StorePremissionsArchive.restartInstance();

            BuyHistoryManager.restartInstance();
            CouponsManager.restartInstance();
            DiscountsManager.restartInstance();
            RaffleSalesManager.restartInstance();
            StorePremissionsArchive.restartInstance();
            zahi = new User("zahi", "123456");
            zahi.register("zahi", "123456");
            zahi.login("zahi", "123456");
            aviad = new User("aviad", "123456");
            aviad.register("aviad", "123456");
            aviad.login("aviad", "123456");
            shay = new User("shay", "123456");
            shay.register("shay", "123456");
            shay.login("shay", "123456");
            itamar = new User("itamar", "123456");
            niv    = new User("niv", "123456");
            niv.register("niv", "123456");
            int storeId = zahi.createStore("abowim");

            store = StoreManagement.getInstance().getStore(storeId);
            int storeId2 = zahi.createStore("broes");

            store2    = StoreManagement.getInstance().getStore(storeId2);
            zahiOwner = new StoreOwner(zahi, store);

            aviadManeger = new StoreManager(aviad, store);
            zahiOwner.addStoreManager(zahi, store, "aviad");
            niv.logOut();
            int colaId = zahiOwner.addProductInStore(zahi, store, "cola", 3.2, 40, "Drinks");

            cola = ProductManager.getInstance().getProductInStore(colaId);
        }