public CompositePurchasePolicy(IPurchasePolicy purchasePolicy1, ILogicOperator @operator, IPurchasePolicy purchasePolicy2, string description)
 {
     Guid            = Guid.NewGuid();
     PurchasePolicy1 = purchasePolicy1;
     Operator        = @operator;
     PurchasePolicy2 = purchasePolicy2;
     Description     = description;
 }
示例#2
0
 public bool UpdatePurchasePolicy(string storeName, IPurchasePolicy policy)
 {
     if (real == null)
     {
         return(true);
     }
     return(real.UpdatePurchasePolicy(storeName, policy));
 }
示例#3
0
文件: Shop.cs 项目: shachafn/wsep192
 public Guid AddNewPurchasePolicy(IPurchasePolicy newPurchasePolicy)
 {
     if (PurchasePolicies == null)
     {
         PurchasePolicies = new List <IPurchasePolicy>();
     }
     PurchasePolicies.Add(newPurchasePolicy);
     return(newPurchasePolicy.Guid);
 }
示例#4
0
 public Guid AddNewPurchasePolicy(Shop shop, IPurchasePolicy newPurchasePolicy)
 {
     if (shop.PurchasePolicies == null)
     {
         shop.PurchasePolicies = new List <IPurchasePolicy>();
     }
     shop.PurchasePolicies.Add(newPurchasePolicy);
     _unitOfWork.ShopRepository.Update(shop);
     return(newPurchasePolicy.Guid);
 }
示例#5
0
        private static void VerifyCartPurchasePolicy(IPurchasePolicy purchasePolicy1, IPurchasePolicy purchasePolicy2)
        {
            var expected = (CartPurchasePolicy)purchasePolicy1;
            var actual   = (CartPurchasePolicy)purchasePolicy2;

            Assert.AreEqual(expected.Guid, actual.Guid);
            Assert.AreEqual(expected.Description, actual.Description);
            Assert.AreEqual(expected.Operator.ToString(), actual.Operator.ToString());
            Assert.AreEqual(expected.ExpectedQuantity, actual.ExpectedQuantity);
        }
示例#6
0
        private static void VerifyUserPurchasePolicy(IPurchasePolicy purchasePolicy1, IPurchasePolicy purchasePolicy2)
        {
            var expected = (UserPurchasePolicy)purchasePolicy1;
            var actual   = (UserPurchasePolicy)purchasePolicy2;

            Assert.AreEqual(expected.Guid, actual.Guid);
            Assert.AreEqual(expected.Description, actual.Description);
            Assert.AreEqual(expected.Value, actual.Value);
            Assert.AreEqual(expected.FieldName, actual.FieldName);
        }
示例#7
0
        private static void VerifyCompositePurchasePolicy(IPurchasePolicy purchasePolicy1, IPurchasePolicy purchasePolicy2)
        {
            var expected = (CompositePurchasePolicy)purchasePolicy1;
            var actual   = (CompositePurchasePolicy)purchasePolicy2;

            Assert.AreEqual(expected.Guid, actual.Guid);
            Assert.AreEqual(expected.Description, actual.Description);
            Assert.AreEqual(expected.Operator.ToString(), actual.Operator.ToString());
            VerifyCartPurchasePolicy(expected.PurchasePolicy1, actual.PurchasePolicy1);
            VerifyUserPurchasePolicy(expected.PurchasePolicy2, actual.PurchasePolicy2);
        }
示例#8
0
        public static bool UpdateStorePolicy(string storeName, IPurchasePolicy newPolicy)
        {
            var store = DataHandler.Instance.GetStore(storeName);

            if (store == null)
            {
                return(false);
            }

            store.GetPurchasePolicies().Add(newPolicy);

            return(true);
        }
示例#9
0
 private bool policyInCompound(Shop shop, IPurchasePolicy policy)
 {
     foreach (IPurchasePolicy p in shop.PurchasePolicies)
     {
         if (p.GetType() == typeof(CompositePurchasePolicy))
         {
             if (((CompositePurchasePolicy)p).PurchasePolicy1.Guid.CompareTo(policy.Guid) == 0 || ((CompositePurchasePolicy)p).PurchasePolicy2.Guid.CompareTo(policy.Guid) == 0)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
示例#10
0
 public bool SetStorePolicy(string userName, string storeName, IPurchasePolicy policy)
 {
     throw new NotImplementedException();
 }
示例#11
0
 public bool UpdatePurchasePolicy(string shopName, IPurchasePolicy policy)
 {
     return(logicInstance.UpdateStorePolicy(shopName, policy));
 }
示例#12
0
 protected bool UpdatePurchasePolicy(string storeName, IPurchasePolicy policy)
 {
     return(service.UpdatePurchasePolicy(storeName, policy));
 }
示例#13
0
文件: Logic.cs 项目: shadyObeed/Sadna
 public bool UpdateStorePolicy(string storeName, IPurchasePolicy newPolicy)
 {
     return(StoreLogic.UpdateStorePolicy(storeName, newPolicy));
 }
示例#14
0
 public Guid AddNewPurchasePolicy(Guid userGuid, Guid shopGuid, IPurchasePolicy newPolicy)
 {
     throw new BadStateException($"Tried to invoke AddNewPurchasePolicy in GuestUser");
 }