예제 #1
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());
     }
 }
예제 #2
0
        public void RemoveCategory()
        {
            var expected = new Category("C2", "Items");
            var find     = handler.GetCategoryByName("Items");

            Assert.IsNull(find);
            handler.AddCategory(expected);
            find = handler.GetCategoryByName("Items");
            Assert.AreEqual(expected, find);
            handler.RemoveCategory(expected);
            find = handler.GetCategoryByName("Items");
            Assert.IsNull(find);
        }