Пример #1
0
        public static void ListOption()
        {
            CalculationRepository calculationRepository = new CalculationRepository();
            var listOfCalculations = calculationRepository.List();

            Console.WriteLine("--------------------------<[ Previous Calculations List ]>--------------------------");
            Console.WriteLine("");

            foreach (var calculation in listOfCalculations)
            {
                string symbol = "";
                switch (calculation.Operation)
                {
                case OperationEnum.Add:
                    symbol = "+";
                    break;

                case OperationEnum.Subtract:
                    symbol = "-";
                    break;

                case OperationEnum.Multiply:
                    symbol = "*";
                    break;

                case OperationEnum.Divide:
                    symbol = "/";
                    break;
                }
                Console.WriteLine("{0} {1} {2} = {3}", calculation.FirstNumber, symbol, calculation.SecondNumber, Calculate(calculation));
            }

            Console.WriteLine("");
            Console.WriteLine("--------------------------<[ Previous Calculations List ]>--------------------------");
        }
Пример #2
0
        static void StoreCalculation(Calculation calculation)
        {
            CalculationRepository calculationRepository = new CalculationRepository();

            calculationRepository.Create(calculation);
        }