Exemplo 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());
        }
Exemplo n.º 2
0
        //req 3.1 b

        /*
         * return:
         *           0 on sucess
         *          -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
         *          -8 if illegal product in store Id
         *          -9 database eror
         */
        public virtual int editProductInStore(User session, int sId, int pisId, int quantity, double price)
        {
            Store     s  = StoreManagement.getInstance().getStore(sId);
            StoreRole sR = StoreRole.getStoreRole(s, session);

            if (s == null)
            {
                return(-6);
            }
            if (sR == null)
            {
                return(-4);//-4 if don't have premition
            }
            ProductInStore p = ProductManager.getInstance().getProductInStore(pisId);

            return(sR.editProductInStore(session, p, quantity, price));
        }