예제 #1
0
        void IDeleteBusiness.deleteCategory()
        {
            _dataDelete.deleteCategory();
            Console.WriteLine("Kindly Enter the category name");
            string categoryName = Console.ReadLine();

            categoryName = char.ToUpper(categoryName[0]) + categoryName.Substring(1).ToLower();
            if (bookAndCategoriesData.retcategories().Find(x => x.categoryName == categoryName && x.Active == true) == null)
            {
                Console.WriteLine("Sorry category doesn't exist.");
            }
            else
            {
                if (bookAndCategoriesData.retcategories().Find(x => x.categoryName == categoryName && x.Active == true && x.cntOfTaggedBooks != 0) != null)
                {
                    Console.WriteLine("Sorry category is tagged to few books and hence you can't delete the category.");
                }
                else
                {
                    bookAndCategoriesData.retcategories().Find(x => x.categoryName == categoryName && x.Active == true && x.cntOfTaggedBooks == 0).Active = false;
                    Console.WriteLine("Category deleted successfully");
                }
            }
        }