public void addTotalAmountPolicy(int minPrice) { if (hasTotalPricePolicy()) { throw new AlreadyExistException("Store can not have 2 total cart price - purchase policy."); } TotalPricePolicy p = new TotalPricePolicy(minPrice); policies.AddLast(p); DBStore.getInstance().addTotalPrice(p, storeId); }
public PurchasePolicy parseRegular(PolicyEntry p) { if (p.getType() == "min") { MinAmountPurchase policy = new MinAmountPurchase(p.getAmount(), p.getPolicyID()); return(policy); } else if (p.getType() == "max") { MaxAmountPurchase policy = new MaxAmountPurchase(p.getAmount(), p.getPolicyID()); return(policy); } else { TotalPricePolicy policy = new TotalPricePolicy(p.getAmount(), p.getPolicyID()); return(policy); } }
public void addTotalPrice(TotalPricePolicy p, int storeID) { try { lock (connection) { connection.Open(); int policyID = p.getPolicyID(); int amount = p.getAmount(); int isPartOfComplex = 0; string type = "total"; string sql = "INSERT INTO [dbo].[PurchasePolicy] (storeID, policyID,type, amount,isPartOfComplex)" + " VALUES (@storeID, @policyID,@type, @amount,@isPartOfComplex )"; connection.Execute(sql, new { storeID, policyID, type, amount, isPartOfComplex }); connection.Close(); } } catch (Exception) { connection.Close(); throw new StoreException("cant add min policy"); } }