public override void Run() { Console.Clear(); UserDatabase userManager = UserDatabase.GetInstance(); ProductDatabase productManager = ProductDatabase.GetInstance(); Console.WriteLine(MenuSystem.Path); Console.WriteLine("List of Products:"); productManager.PrintAll(); int id; do { Console.WriteLine("\nEnter the ID of the product to add to the cart:"); Int32.TryParse("" + Console.ReadKey(false).KeyChar, out id); UserManagement.GetAsCustomer().CartSystem().AddToCart(id); Console.WriteLine("\nWant to add more, press 1 otherwise 0 or any other key:"); Int32.TryParse("" + Console.ReadKey(false).KeyChar, out choice); } while (choice != 0); Console.WriteLine("Press any key to exit.."); Console.ReadKey(); }
public override void Run() { Console.Clear(); UserDatabase userManager = UserDatabase.GetInstance(); ProductDatabase productManager = ProductDatabase.GetInstance(); Console.WriteLine(MenuSystem.Path); Console.WriteLine("1. Add To Cart\n2. Delete From Cart\n3. Return to previous screen"); Console.WriteLine("Enter the choice: "); do { Int32.TryParse("" + Console.ReadKey(false).KeyChar, out choice); switch (choice) { case 1: menuSystem.AddScreen(new AddToCartMenu()); break; case 2: menuSystem.AddScreen(new DeleteFromCartMenu()); break; case 3: return; default: break; } } while (choice != noOfPaths); }
public override void Run() { Console.Clear(); UserDatabase userManager = UserDatabase.GetInstance(); ProductDatabase productManager = ProductDatabase.GetInstance(); Console.WriteLine(MenuSystem.Path); Console.WriteLine("Items in your cart:"); UserManagement.GetAsCustomer().CartSystem().PrintAll(); int sno; do { Console.WriteLine("\nEnter the serial number of the product to delete from the cart:"); Int32.TryParse("" + Console.ReadKey(false).KeyChar, out sno); if (!UserManagement.GetAsCustomer().CartSystem().IsCartEmpty()) { try { UserManagement.GetAsCustomer().CartSystem().DeleteFromCart(sno); } catch (Exception ex) { Console.WriteLine(ex.Message); } } Console.WriteLine("\nWant to delete more or try again, press 1 otherwise 0 or any other key:"); Int32.TryParse("" + Console.ReadKey(false).KeyChar, out choice); } while (choice != 0); }
public static User CreateUserWithWord(Guid wordId, int countToBeLearned) { var user = new User(Guid.NewGuid(), "Bob", new Dictionary <Word, int>(), new Dictionary <Word, int>()) { LearningWords = GetTestWordsWith(wordId, countToBeLearned) .ToDictionary(word => word as Word, _ => 0) }; UserDatabase.GetInstance().SaveUserToFile(user); return(user); }
static UserManagement() { userDBManager = UserDatabase.GetInstance(); }