Esempio n. 1
0
        public ActionResult Index()
        {
            var count = _counterService.GetAll().FirstOrDefault();

            if (count == null)
            {
                _counterService.Add(new Count {
                    CountNo = 1
                });
                count = _counterService.GetAll().FirstOrDefault();
            }

            return(View(ConvertToModel(count)));
        }
Esempio n. 2
0
        public void AcceptCommand()
        {
            Console.Write("Type Command : ");
            var command = Console.ReadLine();

            if (command.Equals("--help"))
            {
                ShowCommands();
                AcceptCommand();
                return;
            }
            ICounter counter = PickCounterFromCommand(command);

            if (counter == null)
            {
                Console.WriteLine(command + " is not command.");
                AcceptCommand();
                return;
            }

            switch (command.Split(' ').First().First())
            {
            case '+':
                counterService.Increment(counter, command.Split(' ').First().Length);
                break;

            case '-':
                counterService.Decrement(counter, command.Split(' ').First().Length);
                break;

            case 'a':
                counterService.Add(counter);
                break;

            case 'd':
                counterService.Delete(counter);
                break;

            default:
                Console.WriteLine(command + " is not command.");
                AcceptCommand();
                return;
            }
        }