Пример #1
0
        public void Run()
        {
            this.writer.WriteLine(OutputMessages.WelcomeString());

            while (true)
            {
                try
                {
                    this.writer.WriteLine(OutputMessages.MenuOptions());

                    var result  = string.Empty;
                    var command = this.reader.ReadLine().Split();

                    if (command[0] == "1")
                    {
                        this.writer.WriteLine(OutputMessages.EnterId);

                        var userId = int.Parse(this.reader.ReadLine());

                        this.writer.WriteLine(OutputMessages.Loading);
                        result = this.FindUser(userId);
                    }
                    else if (command[0] == "2")
                    {
                        this.writer.WriteLine(OutputMessages.EnterIdAndAmount);

                        var tokens = this.reader.ReadLine().Split();
                        var userId = int.Parse(tokens[0]);
                        var amount = decimal.Parse(tokens[1]);

                        this.writer.WriteLine(OutputMessages.Loading);
                        result = this.PayBills(userId, amount);

                        this.context.SaveChanges();
                    }
                    else if (command[0] == "9")
                    {
                        this.writer.WriteLine("Bye bye! 4ao 4ao! Arividerchi! Адиос!");
                        Environment.Exit(0);
                    }

                    this.writer.WriteLine(result);
                }
                catch (Exception)
                {
                    this.writer.WriteLine(OutputMessages.InvalidCommand);
                }
            }
        }
        public void Run()
        {
            this.writer.WriteLine(OutputMessages.WelcomeString());

            while (true)
            {
                try
                {
                    this.writer.WriteLine(OutputMessages.MenuOptions());

                    var result = string.Empty;
                    var input  = this.reader.ReadLine().Split();

                    var command = this.commandInterpreter.InterpretCommand(input);
                    command.Execute();
                }
                catch (Exception)
                {
                    this.writer.WriteLine(OutputMessages.InvalidCommand);
                }
            }
        }