예제 #1
0
        public void AddCategory()
        {
            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);
        }
예제 #2
0
 public void AddCategory(string categoryName)
 {
     try
     {
         MarketLog.Log("StoreCenter", "trying to add category to the store");
         _admin.ValidateSystemAdmin();
         MarketLog.Log("StoreCenter", " check if category name exists");
         CheckIfCategoryExists(categoryName);
         MarketLog.Log("StoreCenter", " adding category");
         if (categoryName.IsNullOrEmpty())
         {
             Answer = new AdminAnswer(EditCategoryStatus.InvalidCategory, "The category name is empty!");
             return;
         }
         Category category = new Category(categoryName);
         _adminDlInstacne.AddCategory(category);
         Answer = new AdminAnswer(EditCategoryStatus.Success, "Category " + categoryName + " added.");
     }
     catch (AdminException e)
     {
         Answer = new AdminAnswer((EditCategoryStatus)e.Status, e.GetErrorMessage());
     }
     catch (DataException e)
     {
         Answer = new AdminAnswer((EditCategoryStatus)e.Status, e.GetErrorMessage());
     }
 }