/// <summary> /// Runs the home functionality page /// </summary> public void Run() { Seeder.Seed(); bool keepGoing = true; while (keepGoing) { HomeView.MainMeny(); var input = InputHelper.ParseInput(); if (userId > 0) { WebbShopAPI api = new WebbShopAPI(); api.Ping(userId); } switch (input) { case 1: userId = new Login().Run(); break; case 2: new User().RegisterAccount(); break; case 3: new Book().Run(); break; case 4: new Purchase().Run(userId); break; case 5: userId = new Admin().Run(); break; case 6: new Logout().Run(userId); keepGoing = false; break; default: MessageViews.DisplayNonAvailableMessage(); break; } } }
/// <summary> /// Runs the purchase functionality page /// </summary> /// <param name="userId"></param> public void Run(int userId) { PurchaseViews.StartPage(); bool keepGoing = true; while (keepGoing) { new Book().FindAllAvailableBooks(); MessageViews.DisplaySelectMessage(); MessageViews.DisplayReturnMessage(); var bookId = InputHelper.ParseInput(); if (bookId == 0) { break; } PurchaseViews.DisplayPurchaseMeny(); MessageViews.DisplayReturnMessage(); var input = InputHelper.ParseInput(); if (input == 0) { break; } switch (input) { case 1: ViewDetails(bookId); break; case 2: PurchaseBook(userId, bookId); keepGoing = false; break; default: MessageViews.DisplayNonAvailableMessage(); break; } } }
/// <summary> /// Runs the book functionality page /// </summary> public void Run() { bool keepGoing = true; while (keepGoing) { BookViews.BookMeny(); var input = InputHelper.ParseInput(); switch (input) { case 1: ViewAllCategories(); break; case 2: SearchFunctionCategories(); break; case 3: SearchBooksByAuthor(); break; case 4: SearchBooksByTitle(); break; case 5: FindAllAvailableBooks(); break; case 6: keepGoing = false; break; default: MessageViews.DisplayNonAvailableMessage(); break; } } }
/// <summary> /// Runs the Admin funtionality-page /// </summary> /// <returns>integer, user id if admin, 0 if not</returns> public int Run() { AdminView.StartPage(); userId = new Login().Run(); if (userId == 0) { return(0); } var result = CheckAdmin(userId); if (!result) { AdminView.VerifyAdminFailed(); return(0); } bool keepGoing = true; while (keepGoing) { AdminView.AdminPage(); var input = InputHelper.ParseInput(); switch (input) { case 1: AddBook(userId); break; case 2: SetAmount(userId); break; case 3: ViewAllUsers(userId); break; case 4: FindUser(userId); break; case 5: UpdateBook(userId); break; case 6: DeleteBook(userId); break; case 7: AddCategory(userId); break; case 8: AddBookToCategory(userId); break; case 9: UpdateCategory(userId); break; case 10: DeleteCategory(userId); break; case 11: AddUser(userId); break; case 12: ViewAllSoldItems(userId); break; case 13: ViewTotalIncome(userId); break; case 14: ViewBestCustomer(userId); break; case 15: PromoteUser(userId); break; case 16: DemoteUser(userId); break; case 17: ActivateUser(userId); break; case 18: InactivateUser(userId); break; case 19: keepGoing = false; break; default: MessageViews.DisplayNonAvailableMessage(); break; } } return(userId); }