コード例 #1
0
        /// <summary>
        /// Method for adding a category to database
        /// </summary>
        /// <param name="admin">Takes a user with admin priviliges</param>
        private static void AddCategory(User admin)
        {
            var continueLoop = true;

            do
            {
                Console.Clear();
                AdminView.AddCategory();
                var input = SharedController.GetSearchInput();
                if (SharedController.CheckIfNullOrEmptyOrWhiteSpace(input))
                {
                    SharedError.PrintWrongInput();
                    continueLoop = true;
                }
                else
                {
                    if (api.AddCategory(admin.Id, input))
                    {
                        SharedError.Success();
                    }
                    else
                    {
                        SharedError.Failed();
                    }
                    continueLoop = false;
                }
            } while (continueLoop);
        }
コード例 #2
0
        /// <summary>
        /// Method for updating the category name of specified category
        /// </summary>
        /// <param name="admin">Takes a user with admin priviliges</param>
        /// <param name="bookCategory">Takes a book category to be updated</param>
        private static void UpdateCategory(User admin, BookCategory bookCategory)
        {
            AdminView.UpdateCategory(bookCategory.Name);
            var input = SharedController.GetSearchInput();

            if (SharedController.CheckIfNullOrEmptyOrWhiteSpace(input))
            {
                SharedError.UnChanged();
            }
            else
            {
                if (api.UpdateCategory(admin.Id, bookCategory.Id, input))
                {
                    SharedError.Success();
                }
                else
                {
                    SharedError.Failed();
                }
            }
        }