Exemplo n.º 1
0
 public CompositePurchasePolicy(IPurchasePolicy purchasePolicy1, ILogicOperator @operator, IPurchasePolicy purchasePolicy2, string description)
 {
     Guid            = Guid.NewGuid();
     PurchasePolicy1 = purchasePolicy1;
     Operator        = @operator;
     PurchasePolicy2 = purchasePolicy2;
     Description     = description;
 }
Exemplo n.º 2
0
 public bool UpdatePurchasePolicy(string storeName, IPurchasePolicy policy)
 {
     if (real == null)
     {
         return(true);
     }
     return(real.UpdatePurchasePolicy(storeName, policy));
 }
Exemplo n.º 3
0
 public Guid AddNewPurchasePolicy(IPurchasePolicy newPurchasePolicy)
 {
     if (PurchasePolicies == null)
     {
         PurchasePolicies = new List <IPurchasePolicy>();
     }
     PurchasePolicies.Add(newPurchasePolicy);
     return(newPurchasePolicy.Guid);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
 }
Exemplo n.º 10
0
 public bool SetStorePolicy(string userName, string storeName, IPurchasePolicy policy)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 11
0
 public bool UpdatePurchasePolicy(string shopName, IPurchasePolicy policy)
 {
     return(logicInstance.UpdateStorePolicy(shopName, policy));
 }
Exemplo n.º 12
0
 protected bool UpdatePurchasePolicy(string storeName, IPurchasePolicy policy)
 {
     return(service.UpdatePurchasePolicy(storeName, policy));
 }
Exemplo n.º 13
0
 public bool UpdateStorePolicy(string storeName, IPurchasePolicy newPolicy)
 {
     return(StoreLogic.UpdateStorePolicy(storeName, newPolicy));
 }
Exemplo n.º 14
0
 public Guid AddNewPurchasePolicy(Guid userGuid, Guid shopGuid, IPurchasePolicy newPolicy)
 {
     throw new BadStateException($"Tried to invoke AddNewPurchasePolicy in GuestUser");
 }