Exemple #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();
                }
            }
        }