public double getRemainingSumToPayInRaffleSale(int saleId) { Sale s = SalesManager.getInstance().getSale(saleId); if (s == null) { return(-2); } ProductInStore p = ProductManager.getInstance().getProductInStore(s.ProductInStoreId); if (p == null) { return(-3); } double price = p.getPrice(); foreach (RaffleSale rs in raffleSales) { if (rs.SaleId == saleId) { price -= rs.Offer; } } return(price); }
public Boolean updateProductInStore(ProductInStore newProduct) { if (newProduct == null) { return(false); } if (newProduct.getProduct() == null || newProduct.getStore() == null || newProduct.getAmount() < 0 || newProduct.getPrice() < 0) { return(false); } foreach (ProductInStore p in productsInStores) { if (p.getProduct().getProductId() == newProduct.getProduct().getProductId() && p.getStore().getStoreId() == newProduct.getStore().getStoreId()) { productInStoreDB.Remove(p); productsInStores.Remove(p); productInStoreDB.Add(newProduct); productsInStores.AddLast(newProduct); return(true); } } return(false); }