Example #1
0
        /// <summary>
        /// Show user info.
        /// </summary>
        public void ShowUserByID()
        {
            using (BillsPaymentSystemContext context = new BillsPaymentSystemContext())
            {
                Console.Clear();
                outputProvider.DrawFrame(2);
                outputProvider.SelectUser();
                while (true)
                {
                    try
                    {
                        Console.Clear();
                        outputProvider.DrawFrame(2);
                        outputProvider.SelectUser();
                        int ID = inputProvider.ReadNumber();
                        if (ID < 0 || ID > context.Users.Count())
                        {
                            throw new Exception(Strings.InvalidInput(ID));
                        }

                        var selectedUser = new SelectedUser(ID);
                        Console.CursorVisible = false;
                        var currentUser  = selectedUser.UserData(context);
                        var bankAccounts = selectedUser.BankAcountData(context);
                        var creditCards  = selectedUser.CreditCardData(context);
                        outputProvider.PrintUserData(currentUser, bankAccounts, creditCards);
                        break;
                    }
                    catch (Exception e)
                    {
                        outputProvider.ShowException(e.Message);
                        if (inputProvider.Key() == ConsoleKey.Enter)
                        {
                            continue;
                        }
                    }
                }

                if (inputProvider.Key() == ConsoleKey.Enter)
                {
                    var inputComander = new InputComander();
                    inputComander.StartReading();
                }
            }
        }
Example #2
0
        public void StartReading()
        {
            int countKeyPressesed = 0;

            outputRenderer.SetWindow();
            outputRenderer.DrawFrame();
            outputRenderer.ShowInitialOptions(countKeyPressesed % elements);

            while (true)
            {
                ConsoleKey keyPressed = inpitProvider.Key();
                inpitProvider.ClearBuffer();

                if (keyPressed == ConsoleKey.UpArrow)
                {
                    countKeyPressesed = countKeyPressesed == 0 ? 4 : countKeyPressesed - 1;
                    outputRenderer.ShowInitialOptions(countKeyPressesed % elements);
                }
                else if (keyPressed == ConsoleKey.DownArrow)
                {
                    countKeyPressesed = countKeyPressesed == 4 ? 0 : countKeyPressesed + 1;
                    outputRenderer.ShowInitialOptions(countKeyPressesed % elements);
                }
                else if (keyPressed == ConsoleKey.Enter)
                {
                    Execute exe = new Execute();
                    outputRenderer.ShowWaiting(countKeyPressesed);
                    methods[countKeyPressesed].Invoke(exe, null);
                    if (countKeyPressesed != 2)
                    {
                        outputRenderer.ShowDone(countKeyPressesed);
                    }
                }
                Thread.Sleep(80);
            }
        }