Beispiel #1
0
        private CalculationTask CreateCalculationTask(CalculatorOperation item1, CalculatorOperation item2, string version)
        {
            var operationtask = calculatorServiceFinder.FindByCalculatorOperation(item2.Operation, version);
            var continueWith  = operationtask.ContinueWith(operation =>
                                                           httpClient.GetStringAsync(operation.Result, item2.Operation, item1.Value, item2.Value));


            return(new CalculationTask(continueWith, item2.Operation));
        }
        public async Task <IActionResult> Index(string version)
        {
            var add = await calculatorServiceFinder.FindByCalculatorOperation(CalculationOperation.Addition, version);

            var sub = await calculatorServiceFinder.FindByCalculatorOperation(CalculationOperation.Substraction, version);

            var mul = await calculatorServiceFinder.FindByCalculatorOperation(CalculationOperation.Multiplication, version);

            var div = await calculatorServiceFinder.FindByCalculatorOperation(CalculationOperation.Division, version);


            var addAvail = new OperationAvailable(CalculationOperation.Addition, add.Any());
            var subAvail = new OperationAvailable(CalculationOperation.Substraction, sub.Any());
            var mulAvail = new OperationAvailable(CalculationOperation.Multiplication, mul.Any());
            var divAvail = new OperationAvailable(CalculationOperation.Division, div.Any());

            var operationAvailables = new List <OperationAvailable> {
                addAvail, subAvail, mulAvail, divAvail
            };

            return(Ok(operationAvailables));
        }