Пример #1
0
 public void RemoveProductFromCategory(string categoryName, string productName)
 {
     try
     {
         MarketLog.Log("StoreCenter", "trying to remove product from category in the store");
         MarketLog.Log("StoreCenter", "check if store exists");
         checkIfStoreExistsAndActive();
         MarketLog.Log("StoreCenter", " store exists");
         MarketLog.Log("StoreCenter", " check if has premmision to handle categorys");
         _storeManager.CanManageProducts();
         MarketLog.Log("StoreCenter", " has premmission");
         MarketLog.Log("StoreCenter", " check if category name exists in the store " + _storeName);
         string storeid = GetStoreIDbyName();
         CheckIfCategoryExistsInStore(categoryName, storeid);
         MarketLog.Log("StoreCenter", "Check if Product exists in store");
         var product = DataLayerInstance.GetProductByNameFromStore(_storeName, productName);
         checkifProductExists(product);
         MarketLog.Log("StoreCenter", "Product exists");
         MarketLog.Log("StoreCenter", "Check if product in this category");
         Category category = DataLayerInstance.GetCategoryByName(categoryName);
         CheckifProductInCategory(product, category.SystemId);
         MarketLog.Log("StoreCenter", "Product is in category");
         DataLayerInstance.RemoveProductFromCategory(category.SystemId, product.SystemId);
         Answer = new StoreAnswer(StoreEnum.Success,
                                  "product " + productName + " removed successfully from category " + categoryName);
     }
     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");
     }
 }