/// <summary> /// Method for editing the user. Promote, Demote, activate or deactivate /// </summary> /// <param name="admin">Takes a user with admin priviliges</param> /// <param name="editUser">Takes a user to edit</param> private static void EditUser(User admin, User editUser) { var continueLoop = true; do { AdminView.EditUser(editUser); var input = SharedController.GetAndValidateInput(); switch (input.validatedInput) { case 1: if (api.Promote(admin.Id, editUser.Id)) { SharedError.Success(); break; } SharedError.Failed(); break; case 2: if (api.Demote(admin.Id, editUser.Id)) { SharedError.Success(); break; } SharedError.Failed(); break; case 3: if (api.ActivateUser(admin.Id, editUser.Id)) { SharedError.Success(); break; } SharedError.Failed(); break; case 4: if (api.InactivateUser(admin.Id, editUser.Id)) { SharedError.Success(); break; } SharedError.Failed(); break; case 0: continueLoop = SharedController.GoBackIf_X_IsPressedOrPrintErrorMsg(input.menuInput); break; default: SharedError.PrintWrongMenuInput(); break; } } while (continueLoop); }
/// <summary> /// Method for handling the input for the book options /// </summary> /// <param name="book">Takes a book</param> /// <param name="admin">Takes a user with admin priviliges</param> public static void BookOptions(Book book, User admin) { var continueLoop = true; do { Console.Clear(); if (book.Amount == 0) { continueLoop = false; continue; } AdminView.UpdateBook(book); var input = SharedController.GetAndValidateInput(); switch (input.validatedInput) { case 1: Console.Clear(); SetAmount(book, admin); break; case 2: Console.Clear(); UpdateBookInfo(book, admin); break; case 3: Console.Clear(); ChangeCategory(book, admin); break; case 4: DeleteBook(book, admin); break; case 0: continueLoop = SharedController.GoBackIf_X_IsPressedOrPrintErrorMsg(input.menuInput); break; default: SharedError.PrintWrongMenuInput(); break; } } while (continueLoop); }
/// <summary> /// Method for updating the information of a book /// </summary> /// <param name="book">Takes a book to update</param> /// <param name="admin">Takes a user with admin priviliges</param> private static void UpdateBookInfo(Book book, User admin) { var continueLoop = true; do { Console.Clear(); AdminView.UpdateBookInfo(book); var input = SharedController.GetAndValidateInput(); switch (input.validatedInput) { case 1: Console.Clear(); ChangeTitle(admin, book); break; case 2: Console.Clear(); ChangeAuthor(admin, book); break; case 3: Console.Clear(); ChangePrice(admin, book); break; case 4: Console.Clear(); ChangeCategory(book, admin); break; case 0: continueLoop = SharedController.GoBackIf_X_IsPressedOrPrintErrorMsg(input.menuInput); break; default: SharedError.PrintWrongMenuInput(); break; } } while (continueLoop); }
/// <summary> /// Prints all admin functions and takes a menuinput /// </summary> /// <param name="admin">Takes a user with admin priviliges</param> private static void AdminFunctions(User admin) { var continueLoop = true; do { AdminView.PrintAdminFunctions(); var input = SharedController.GetAndValidateInput(); switch (input.validatedInput) { case 1: AddUser(admin); break; case 2: ListAllUsers(admin); break; case 3: SearchForUser(admin); break; case 4: AddBook(admin); break; case 5: GetBookAndEnterBookOptions(admin); break; case 6: GetBookAndEnterBookOptions(admin); break; case 7: GetAllBooksAndEnterBookOptions(admin); break; case 8: AddCategory(admin); break; case 9: DeleteCategory(admin); break; case 10: UpdateCategory(admin); break; case 11: SoldBooks(admin); break; case 12: Earnings(admin); break; case 13: BestCustomer(admin); break; case 0: continueLoop = SharedController.GoBackIf_X_IsPressedOrPrintErrorMsg(input.menuInput); break; } } while (continueLoop); }