Esempio n. 1
0
 public void ViewPolicies()
 {
     try
     {
         MarketLog.Log("AdminView", "Checking admin status.");
         _admin.ValidateSystemAdmin();
         Category[]    catList = _adminDL.GetAllCategories();
         List <string> result  = new List <string>();
         foreach (var cat in catList)
         {
             result.Add(cat.Name);
         }
         Answer = new AdminAnswer(ViewPolicyStatus.Success, "Successfully got all category names.", result.ToArray());
     }
     catch (AdminException e)
     {
         Answer = new AdminAnswer((ViewPolicyStatus)e.Status, e.GetErrorMessage());
     }
     catch (DataException e)
     {
         Answer = new AdminAnswer((ViewPolicyStatus)e.Status, e.GetErrorMessage());
     }
     catch (MarketException e)
     {
         Answer = new AdminAnswer(ViewPolicyStatus.NoAuthority, e.GetErrorMessage(), null);
     }
 }
Esempio n. 2
0
        public void NoUserFoundToPromote()
        {
            _storeManager1.GetStoreManagementService(_bridgeSignUp.GetUserSession(), "basush");
            MarketAnswer res = _storeManager1.PromoteToStoreManager("euro", "StoreOwner");

            Assert.AreEqual((int)PromoteStoreStatus.NoUserFound, res.Status);
        }
Esempio n. 3
0
 public void ViewStoreInfo(string store)
 {
     try
     {
         CheckIfStoreExistsAndActive(store);
         MarketLog.Log("StoreCenter", "check that have premission to view store info");
         _shopper.ValidateCanBrowseMarket();
         MarketLog.Log("StoreCenter", "premission gained");
         string[] storeInfo = storeLogic.GetStoreInfo(store);
         CheckIfStoreInfoIsNotNull(storeInfo);
         MarketLog.Log("StoreCenter", "info gained");
         answer = new StoreAnswer(ViewStoreStatus.Success, "Store info has been successfully granted!", storeInfo);
     }
     catch (StoreException e)
     {
         MarketLog.Log("StoreCenter", "");
         answer = new StoreAnswer((ViewStoreStatus)e.Status, "Something is wrong with viewing " + store +
                                  " info by customers . Error message has been created!");
     }
     catch (DataException e)
     {
         answer = new StoreAnswer((StoreEnum)e.Status, e.GetErrorMessage());
     }
     catch (MarketException)
     {
         MarketLog.Log("StoreCenter", "no premission");
         answer = new StoreAnswer(ViewStoreStatus.InvalidUser,
                                  "User validation as valid customer has been failed . only valid users can browse market. Error message has been created!");
     }
 }
Esempio n. 4
0
        public void ChangeProductPurchaseWayToImmediate(string productName)
        {
            try
            {
                MarketLog.Log("StoreCenter", "trying to edit discount from product in store");
                checkIfStoreExistsAndActive();
                MarketLog.Log("StoreCenter", " check if has premmision to edit product purches type");
                _storeManager.CanManageProducts();
                MarketLog.Log("StoreCenter", "check if product exists");
                checkifProductExists(DataLayerInstance.GetProductByNameFromStore(_storeName, productName));
                MarketLog.Log("StoreCenter", "product exists");
                StockListItem stockList = DataLayerInstance.GetProductFromStore(_storeName, productName);
                ValidateLottery(stockList);
                stockList.PurchaseWay = PurchaseEnum.Immediate;
                DataLayerInstance.EditStockInDatabase(stockList);
                answer = new StoreAnswer(StoreEnum.Success, "purches way changed");
            }
            catch (StoreException exe)
            {
                answer = new StoreAnswer((StoreEnum)exe.Status, exe.GetErrorMessage());
            }

            catch (DataException e)
            {
                answer = new StoreAnswer((StoreEnum)e.Status, e.GetErrorMessage());
            }

            catch (MarketException)
            {
                answer = new StoreAnswer(StoreEnum.NoPermission, "you have no premmision to do that");
            }
        }
Esempio n. 5
0
        public void NotOwnerTriesToPromoteToOwner()
        {
            _storeManager1.GetStoreManagementService(_userToPromoteBridge.GetUserSession(), "basush");
            MarketAnswer res = _storeManager1.PromoteToStoreManager("blah", "StoreOwner");

            Assert.AreEqual((int)PromoteStoreStatus.NoAuthority, res.Status);
        }
Esempio n. 6
0
        public void ProductNotFoundInTheStore()
        {
            _storeManage1.GetStoreManagementService(_userBridge.GetUserSession(), "lokef");
            MarketAnswer res = _storeManage1.RemoveProduct("bambuu");

            Assert.AreEqual((int)StoreEnum.ProductNotFound, res.Status);
        }
Esempio n. 7
0
        public void SuccessAddingProductToCartGRegisteredUser()
        {
            MarketAnswer res1 = _storeBridge.AddProductToCart("BlahStore", "bisli", 1);

            Assert.AreEqual((int)StoreEnum.Success, res1.Status);
            MarketAnswer res2 = _storeBridge.AddProductToCart("BlahStore", "cheaps", 2);

            Assert.AreEqual((int)StoreEnum.Success, res2.Status);
            MarketAnswer res3 = _storeBridge.AddProductToCart("BlahStore2", "doritos", 3);

            Assert.AreEqual((int)StoreEnum.Success, res3.Status);
            //Lets view to cart to see the products were indeed added.
            MarketAnswer cartDetails = _signInBridge.ViewCart();

            string[] cartItemsExpected =
            {
                "Name : bisli Store : BlahStore Quantity : 1 Unit Price : 200 Final Price : 200",
                "Name : cheaps Store : BlahStore Quantity : 2 Unit Price : 20 Final Price : 40",
                "Name : doritos Store : BlahStore2 Quantity : 3 Unit Price : 30 Final Price : 90"
            };

            string[] cartItemsReceived = cartDetails.ReportList;
            Assert.AreEqual(cartItemsExpected.Length, cartItemsReceived.Length);
            for (int i = 0; i < cartItemsReceived.Length; i++)
            {
                Assert.AreEqual(cartItemsExpected[i], cartItemsReceived[i]);
            }
        }
Esempio n. 8
0
        private void InitiateOrder(int systemId, string userName, string userAddress, string userCreditCard)
        {
            var userService = MarketServer.Users[systemId];

            orderService = MarketYard.Instance.GetOrderService(ref userService);
            answer       = orderService.GiveDetails(userName, userAddress, userCreditCard);
        }
Esempio n. 9
0
 public void EditProduct(string productName, string productNewName, string basePrice, string description)
 {
     try
     {
         MarketLog.Log("StoreCenter", "trying to edit product in store");
         checkIfStoreExistsAndActive();
         MarketLog.Log("StoreCenter", " store exists");
         MarketLog.Log("StoreCenter", " check if has premmision to edit products");
         _storeManager.CanManageProducts();
         MarketLog.Log("StoreCenter", " has premmission");
         MarketLog.Log("StoreCenter", " check if product name exists in the store " + _storeName);
         Product product = DataLayerInstance.GetProductByNameFromStore(_storeName, productName);
         checkifProductExists(product);
         EditAllProductFields(productNewName, basePrice, description, ref product);
         answer = new StoreAnswer(StoreEnum.Success, "Product has been updated!");
         CheckIfNoLegalFound();
         DataLayerInstance.EditProductInDatabase(product);
     }
     catch (StoreException exe)
     {
         answer = new StoreAnswer((StoreEnum)exe.Status, exe.GetErrorMessage());
     }
     catch (DataException e)
     {
         answer = new StoreAnswer((StoreEnum)e.Status, e.GetErrorMessage());
     }
     catch (MarketException)
     {
         MarketLog.Log("StoreCenter", "no premission");
         answer = new StoreAnswer(StoreEnum.NoPermission, "you have no premmision to do that");
     }
 }
Esempio n. 10
0
        public void GuestViewStock()
        {
            UserWatchStockInitialize();
            MarketAnswer stockDetails = _storeBridgeGuest.ViewStoreStock("OOF");

            WatchStockAndCompare(stockDetails);
        }
Esempio n. 11
0
        public void NoStoreExistsRegisteredUserViewStock()
        {
            MarketAnswer stockDetails = _storeBridge.ViewStoreStock("OOFA");

            Assert.AreEqual((int)StoreEnum.StoreNotExists, stockDetails.Status);
            Assert.IsNull(stockDetails.ReportList);
        }
Esempio n. 12
0
        public void DidntEnterSystemChangeQuantity()
        {
            _bridgeGuest2 = UserDriver.getBridge();
            MarketAnswer res = _bridgeGuest2.EditCartItem("BlahStore", "bisli", 1, 200);

            Assert.AreEqual((int)EditCartItemStatus.DidntEnterSystem, res.Status);
        }
Esempio n. 13
0
        private void CheckCartSameStockNotChangedGuest()
        {
            MarketAnswer cartDetails = _buyerGuestBridge.ViewCart();

            string[] received = cartDetails.ReportList;
            string[] expected =
            {
                "Name : Coffee Store : HAHAHA Quantity : 3 Unit Price : 10 Final Price : 30",
                "Name : Tea Store : Yalla Quantity : 4 Unit Price : 10 Final Price : 40"
            };

            Assert.AreEqual(expected.Length, received.Length);
            for (int i = 0; i < received.Length; i++)
            {
                Assert.AreEqual(expected[i], received[i]);
            }
            MarketAnswer stock1 = _shoppingBridge.ViewStoreStock("Yalla");

            string[] expectedYallaStock =
            {
                " name: Tea base price: 10 description: CherryFlavour Discount: {null} Purchase Way: Immediate Quantity: 6"
            };
            Assert.AreEqual(expectedYallaStock[0], stock1.ReportList[0]);
            MarketAnswer stock2 = _shoppingBridge.ViewStoreStock("HAHAHA");

            string[] expectedHahahaStock =
            {
                " name: Coffee base price: 10 description: Black Discount: {null} Purchase Way: Immediate Quantity: 6"
            };
            Assert.AreEqual(expectedHahahaStock[0], stock2.ReportList[0]);
        }
Esempio n. 14
0
        public void SuccessBuyingProductsGuest()
        {
            AddProductsToCartGuest();
            _orderBridge.GetOrderService(_buyerGuestBridge.GetUserSession());
            _orderBridge.GiveDetails("PninaGuest", "MisholGuest", "77777777");
            MarketAnswer order = _orderBridge.BuyEverythingFromCart(new string[] { null, null });

            Assert.AreEqual((int)OrderStatus.Success, order.Status);

            MarketAnswer cartDetails = _buyerGuestBridge.ViewCart();

            string[] expectedCart = { };
            string[] receivedCart = cartDetails.ReportList;
            Assert.AreEqual(expectedCart.Length, receivedCart.Length);
            MarketAnswer stock1 = _shoppingBridge.ViewStoreStock("Yalla");

            string[] expectedYallaStock =
            {
                " name: Tea base price: 10 description: CherryFlavour Discount: {null} Purchase Way: Immediate Quantity: 2"
            };
            Assert.AreEqual(expectedYallaStock[0], stock1.ReportList[0]);
            MarketAnswer stock2 = _shoppingBridge.ViewStoreStock("HAHAHA");

            string[] expectedHahahaStock =
            {
                " name: Coffee base price: 10 description: Black Discount: {null} Purchase Way: Immediate Quantity: 3"
            };
            Assert.AreEqual(expectedHahahaStock[0], stock2.ReportList[0]);
        }
Esempio n. 15
0
 public void RemoveDiscountFromProduct(string productName)
 {
     try
     {
         MarketLog.Log("StoreCenter", "trying to remove discount from product in store");
         MarketLog.Log("StoreCenter", "check if store exists");
         checkIfStoreExistsAndActive();
         MarketLog.Log("StoreCenter", " check if has premmision to edit products");
         _storeManager.CanDeclareDiscountPolicy();
         MarketLog.Log("StoreCenter", " has premmission");
         Product P = DataLayerInstance.GetProductByNameFromStore(_storeName, productName);
         checkifProductExists(P);
         Discount      D             = CheckIfDiscountExistsPrivateMethod(productName);
         StockListItem stockListItem = DataLayerInstance.GetProductFromStore(_storeName, productName);
         stockListItem.Discount = null;
         DataLayerInstance.RemoveDiscount(D);
         DataLayerInstance.EditStockInDatabase(stockListItem);
         MarketLog.Log("StoreCenter", "discount removed successfully");
         Answer = new StoreAnswer(DiscountStatus.Success, "discount removed successfully");
     }
     catch (StoreException exe)
     {
         Answer = new StoreAnswer((StoreEnum)exe.Status, exe.GetErrorMessage());
     }
     catch (DataException e)
     {
         Answer = new StoreAnswer((StoreEnum)e.Status, e.GetErrorMessage());
     }
     catch (MarketException)
     {
         Answer = new StoreAnswer(StoreEnum.NoPermission, "you have no premmision to do that");
     }
 }
Esempio n. 16
0
        public void NoStoreExistsRegisteredUserViewStore()
        {
            MarketAnswer storeDetails = _storeBridge.ViewStoreInfo("OOFA");

            Assert.AreEqual((int)ViewStoreStatus.NoStore, storeDetails.Status);
            Assert.AreEqual(null, storeDetails.ReportList);
        }
Esempio n. 17
0
 public void RemoveCategory(string categoryName)
 {
     try
     {
         MarketLog.Log("StoreCenter", "trying to remove category from the system");
         MarketLog.Log("StoreCenter", " check if category name exists");
         CheckIfCategoryExists(categoryName);
         MarketLog.Log("StoreCenter", " removing category");
         if (categoryName.IsNullOrEmpty())
         {
             Answer = new AdminAnswer(EditCategoryStatus.InvalidCategory, "The category name is empty!");
         }
         Category category = _adminDlInstacne.GetCategoryByName(categoryName);
         _adminDlInstacne.RemoveCategory(category);
         Answer = new AdminAnswer(EditCategoryStatus.Success, "Category " + categoryName + " removed.");
     }
     catch (AdminException e)
     {
         Answer = new AdminAnswer((EditCategoryStatus)e.Status, e.GetErrorMessage());
     }
     catch (DataException e)
     {
         Answer = new AdminAnswer((EditCategoryStatus)e.Status, e.GetErrorMessage());
     }
 }
Esempio n. 18
0
 public void AddProductToCart(string store, string productName, int quantity)
 {
     try
     {
         MarketLog.Log("StoreCenter", "trying to add something to the cart");
         MarketLog.Log("StoreCenter", "checking if store exists");
         CheckIfStoreExitsts(store);
         MarketLog.Log("StoreCenter", "checking if user has premmisions");
         _shopper.ValidateCanBrowseMarket();
         MarketLog.Log("StoreCenter", "checking if product exists");
         CheckIsProductNameAvailableInStore(store, productName);
         StockListItem stockListItem = storeLogic.GetProductFromStore(store, productName);
         CheckifQuantityIsOK(quantity, stockListItem);
         stockListItem.CheckIfDiscountExistsAndCalcValue(store);
         _shopper.AddToCart(stockListItem.Product, stockListItem.Product.Categories, store, quantity);
         MarketLog.Log("StoreCenter", "add product successeded");
         answer = new StoreAnswer(StoreEnum.Success, quantity + " " + productName + " from " + store + "has been" +
                                  " successfully added to the user's cart!");
     }
     catch (StoreException e)
     {
         answer = new StoreAnswer((AddProductStatus)e.Status, "There is no product or store or quantity of that type in the market." +
                                  " request has been denied. Error message has been created!");
     }
     catch (DataException e)
     {
         answer = new StoreAnswer((StoreEnum)e.Status, e.GetErrorMessage());
     }
     catch (MarketException)
     {
         answer = new StoreAnswer(StoreEnum.NoPermission,
                                  "User validation as valid customer has been failed . only valid users can browse market. Error message has been created!");
     }
 }
Esempio n. 19
0
        public void SuccessAddingProductToCartGuest()
        {
            _bridgeSignUp.EnterSystem();
            _storeBridge3 = StoreShoppingDriver.getBridge();
            _storeBridge3.GetStoreShoppingService(_bridgeSignUp.GetUserSession());
            MarketAnswer res1 = _storeBridge3.AddProductToCart("BlahStore", "bisli", 1);

            Assert.AreEqual((int)StoreEnum.Success, res1.Status);
            MarketAnswer res2 = _storeBridge3.AddProductToCart("BlahStore", "cheaps", 2);

            Assert.AreEqual((int)StoreEnum.Success, res2.Status);
            MarketAnswer res3 = _storeBridge3.AddProductToCart("BlahStore2", "doritos", 3);

            Assert.AreEqual((int)StoreEnum.Success, res3.Status);
            //Lets view to cart to see the products were indeed added.
            MarketAnswer cartDetails = _bridgeSignUp.ViewCart();

            string[] cartItemsExpected =
            {
                "Name : bisli Store : BlahStore Quantity : 1 Unit Price : 200 Final Price : 200",
                "Name : cheaps Store : BlahStore Quantity : 2 Unit Price : 20 Final Price : 40",
                "Name : doritos Store : BlahStore2 Quantity : 3 Unit Price : 30 Final Price : 90"
            };

            string[] cartItemsReceived = cartDetails.ReportList;
            Assert.AreEqual(cartItemsExpected.Length, cartItemsReceived.Length);
            for (int i = 0; i < cartItemsReceived.Length; i++)
            {
                Assert.AreEqual(cartItemsExpected[i], cartItemsReceived[i]);
            }
        }
Esempio n. 20
0
 public StockListItem AddNewProduct(string name, double price, string description, int quantity)
 {
     try
     {
         Store store = DataLayerInstance.GetStorebyName(_storeName);
         MarketLog.Log("StoreCenter", "trying to add product to store");
         checkIfStoreExistsAndActive();
         MarketLog.Log("StoreCenter", " store exists");
         MarketLog.Log("StoreCenter", " check if has premmision to add products");
         _storeManager.CanManageProducts();
         MarketLog.Log("StoreCenter", " has premmission");
         MarketLog.Log("StoreCenter", " check if product name avlaiable in the store" + _storeName);
         CheckInput(name, price, description, quantity);
         MarketLog.Log("StoreCenter", " Input is valid.");
         Product       product       = new Product(name, price, description);
         StockListItem stockListItem = new StockListItem(quantity, product, null, PurchaseEnum.Immediate, store.SystemId);
         DataLayerInstance.AddStockListItemToDataBase(stockListItem);
         MarketLog.Log("StoreCenter", "product added");
         answer = new StoreAnswer(StoreEnum.Success, "product added");
         return(stockListItem);
     }
     catch (StoreException e)
     {
         answer = new StoreAnswer((StoreEnum)e.Status, e.GetErrorMessage());
     }
     catch (DataException e)
     {
         answer = new StoreAnswer((StoreEnum)e.Status, e.GetErrorMessage());
     }
     catch (MarketException)
     {
         answer = new StoreAnswer(StoreEnum.NoPermission, "you have no premmision to do that");
     }
     return(null);
 }
Esempio n. 21
0
 public void RemovePolicy(string type, string subject)
 {
     try
     {
         MarketLog.Log("AdminView", "Checking admin status.");
         _admin.ValidateSystemAdmin();
         MarketLog.Log("AdminView", "Trying to remove policy.");
         CheckInput(type, subject);
         _manager.RemovePolicy(GetPolicyType(type), subject);
         MarketLog.Log("AdminView", "Policy removed successfully.");
         Answer = new AdminAnswer(EditPolicyStatus.Success, "Policy removed.");
     }
     catch (AdminException e)
     {
         Answer = new AdminAnswer((EditPolicyStatus)e.Status, e.GetErrorMessage());
     }
     catch (DataException e)
     {
         Answer = new AdminAnswer((EditPolicyStatus)e.Status, e.GetErrorMessage());
     }
     catch (MarketException e)
     {
         Answer = new AdminAnswer(EditPolicyStatus.NoAuthority, e.GetErrorMessage());
     }
 }
Esempio n. 22
0
        public void DidntEnterSystemRemoveItem()
        {
            _bridgeGuest2 = UserDriver.getBridge();
            MarketAnswer res = _bridgeGuest2.RemoveFromCart("BlahStore2", "doritos", 30);

            Assert.AreEqual((int)RemoveFromCartStatus.DidntEnterSystem, res.Status);
        }
Esempio n. 23
0
 public void PromoteToStoreManager(string someoneToPromoteName, string actions)
 {
     try
     {
         MarketLog.Log("StoreCenter", "Manager " + _storeManager.GetID() + " attempting to grant " + someoneToPromoteName +
                       " manager options in Store" + _storeName + ". Validating store activity and existence..");
         checkIfStoreExistsAndActive();
         ValidatePromotionEligible(actions);
         _storeManager.ValidateNotPromotingHimself(someoneToPromoteName);
         MarketLog.Log("StoreCenter", "Manager " + _storeManager.GetID() + " has been authorized. granting " +
                       someoneToPromoteName + " manager options in Store" + _storeName + "...");
         var appliedPermissions = _storeManager.Promote(someoneToPromoteName, actions);
         DataLayerInstance.AddPromotionHistory(_storeName, _storeManager.GetName(), someoneToPromoteName, appliedPermissions, "Regular promotion");
         MarketLog.Log("StoreCenter", "Manager " + _storeManager.GetID() + " granted " +
                       someoneToPromoteName + " manager options in Store" + _storeName + "successfully");
         Answer = new StoreAnswer(PromoteStoreStatus.Success, "promote with manager options has been successful!");
     }
     catch (StoreException e)
     {
         Answer = new StoreAnswer(PromoteStoreStatus.InvalidStore, e.GetErrorMessage());
     }
     catch (DataException e)
     {
         Answer = new StoreAnswer((StoreEnum)e.Status, e.GetErrorMessage());
     }
     catch (MarketException e)
     {
         Answer = new StoreAnswer((PromoteStoreStatus)e.Status, e.GetErrorMessage());
     }
 }
Esempio n. 24
0
        public void ViewStoreNoPremission()
        {
            StoreShoppingService liorSession = (StoreShoppingService)market.GetStoreShoppingService(ref userService);
            MarketAnswer         ans         = liorSession.ViewStoreInfo("X");

            Assert.AreEqual((int)ViewStoreStatus.InvalidUser, ans.Status);
        }
Esempio n. 25
0
        public void PromotesHimselfToOwner()
        {
            _storeManager1.GetStoreManagementService(_bridgeSignUp.GetUserSession(), "basush");
            MarketAnswer res = _storeManager1.PromoteToStoreManager("LAMA", "StoreOwner");

            Assert.AreEqual((int)PromoteStoreStatus.PromoteSelf, res.Status);
        }
Esempio n. 26
0
 public void ViewStoreHistory()
 {
     try
     {
         Store store = DataLayerInstance.GetStorebyName(_storeName);
         MarketLog.Log("StoreCenter", "Manager " + _storeManager.GetID() + " attempting to view the store purchase history...");
         checkIfStoreExistsAndActive();
         _storeManager.CanViewPurchaseHistory();
         var historyReport = DataLayerInstance.GetHistory(store);
         answer = new StoreAnswer(ViewStorePurchaseHistoryStatus.Success, "View purchase history has been successful!", historyReport);
     }
     catch (StoreException e)
     {
         MarketLog.Log("StoreCenter", "Manager " + _storeManager.GetID() + " tried to view purchase history in unavailable Store " + _storeName +
                       "and has been denied. Error message has been created!");
         answer = new StoreAnswer(ManageStoreStatus.InvalidStore, e.GetErrorMessage());
     }
     catch (DataException e)
     {
         answer = new StoreAnswer((StoreEnum)e.Status, e.GetErrorMessage());
     }
     catch (MarketException e)
     {
         MarketLog.Log("StoreCenter", "Manager " + _storeManager.GetID() + " has no permission to view purchase history in Store"
                       + _storeName + " and therefore has been denied. Error message has been created!");
         answer = new StoreAnswer(ManageStoreStatus.InvalidManager, e.GetErrorMessage());
     }
 }
Esempio n. 27
0
        public void InvalidStore()
        {
            _storeManager1.GetStoreManagementService(_bridgeSignUp.GetUserSession(), "mahar");
            MarketAnswer res = _storeManager1.PromoteToStoreManager("eurovision", "StoreOwner");

            Assert.AreEqual((int)PromoteStoreStatus.InvalidStore, res.Status);
        }
Esempio n. 28
0
 public void ViewPromotionHistory()
 {
     try
     {
         MarketLog.Log("StoreCenter", "Trying to view promotion history in store");
         checkIfStoreExistsAndActive();
         MarketLog.Log("StoreCenter", "Validate that can watch promotion history of that store");
         _storeManager.CanPromoteStoreOwner();
         MarketLog.Log("StoreCenter", "Retreiving the store promotion history records");
         var historyRecords = DataLayerInstance.GetPromotionHistory(_storeName);
         MarketLog.Log("StoreCenter", "'View Promotion History' has been successfully done on store '" + _storeName + "'");
         Answer = new StoreAnswer(StoreEnum.Success,
                                  "Successfully has been retrived the store promotion history records", historyRecords);
     }
     catch (StoreException e)
     {
         Answer = new StoreAnswer((StoreEnum)e.Status, e.GetErrorMessage());
     }
     catch (DataException e)
     {
         Answer = new StoreAnswer((StoreEnum)e.Status, e.GetErrorMessage());
     }
     catch (MarketException)
     {
         Answer = new StoreAnswer(StoreEnum.NoPermission, "you have no premmision to do that");
     }
 }
Esempio n. 29
0
        public void DidntEnterSystemViewCart()
        {
            MarketAnswer res = _bridge.ViewCart();

            Assert.AreEqual((int)ViewCartStatus.DidntEnterSystem, res.Status);
            Assert.IsNull(res.ReportList);
        }
Esempio n. 30
0
 public Store OpenStore(string storeName, string address)
 {
     try
     {
         MarketLog.Log("StoreCenter", "trying to add new store");
         _shopper.ValidateRegistered();
         MarketLog.Log("StoreCenter", "premission gained");
         CheckIfNameAvailable(storeName);
         CheckIfDataValid(address);
         MarketLog.Log("StoreCenter", "data is valid");
         Store newStore = new Store(storeName, address);
         storeDB.AddStore(newStore);
         MarketLog.Log("StoreCenter", "store was opened");
         _shopper.AddOwnership(storeName);
         storeDB.AddPromotionHistory(storeName, _shopper.GetShopperName(), _shopper.GetShopperName(), new[] { "StoreOwner" }, storeName + " has been opened");
         Answer = new StoreAnswer(OpenStoreStatus.Success, "Store " + storeName + " has been opened successfully");
         return(newStore);
     }
     catch (StoreException e)
     {
         Answer = new StoreAnswer((OpenStoreStatus)e.Status, e.GetErrorMessage());
     }
     catch (DataException e)
     {
         Answer = new StoreAnswer((StoreEnum)e.Status, e.GetErrorMessage());
     }
     catch (MarketException)
     {
         Answer = new StoreAnswer(OpenStoreStatus.InvalidUser,
                                  "User validation as store owner has been failed. only registered users can open new stores.");
     }
     return(null);
 }