public void EditeSaleeWithManagerPermission() { zahiOwner.addManagerPermission(zahi, "editSale", store, "aviad"); int saleId = zahiOwner.addSaleToStore(aviad, store, cola.getProductInStoreId(), 1, 1, DateTime.Now.AddMonths(1).ToString()); Assert.AreEqual(store.getAllSales().Count, 1); Assert.IsTrue(aviadManeger.editSale(aviad, store, saleId, 2, DateTime.Now.AddMonths(1).ToString()) > -1); Assert.AreEqual(store.getAllSales().Count, 1); Assert.AreEqual(store.getAllSales().First.Value.Amount, 2); }
/* * return: * 0 on sucess the SaleID * -1 if user Not Login * -4 if don't have premition * -5 if illegal amount bigger then amount in stock * -6 if illegal store id * -7 if illegal price * -8 if illegal sale id * -9 database eror * -10 due date not good * -12 if illegal amount */ public int editSale(User session, int storeId, int saleId, int amount, String dueDate) { Store s = StoreManagement.getInstance().getStore(storeId); StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(-4);//-4 if don't have premition } return(sR.editSale(session, s, saleId, amount, dueDate)); }