public IActionResult AddNumbers([FromBody] NumberReq req)
        {
            try
            {
                var number1 = req.number1;
                var number2 = req.number2;

                OperatorService osService = new OperatorService(number1, number2);

                Calculation calculation = new Calculation();
                calculation.Number1 = number1;
                calculation.Number2 = number2;
                calculation.LogTime = DateTime.Now;
                calculation.Operand = osService.OperandString;
                calculation.Result  = new OperatorService(number1, number2).Calculate();

                calcRepo.AddCalculationResult(calculation);
            }
            catch (Exception ex)
            {
                filer.LogError(ex.Message);
            }

            return(Ok());
        }
예제 #2
0
        public override Task <NumberRes> Multiply(NumberReq request, ServerCallContext context)
        {
            var numberResponse = new NumberRes
            {
                Number = (int)Math.Pow(request.Number, 2)
            };

            return(Task.FromResult(numberResponse));
        }
예제 #3
0
        public override Task <NumberRes> Sum(NumberReq request, ServerCallContext context)
        {
            var response = new NumberRes()
            {
                Number = request.Number * 2
            };

            return(Task.FromResult(response));
        }
 public async Task <NumberRes> GetSumAsync(NumberReq req)
 {
     return(await _client.SumAsync(req));
 }
 public async Task <NumberRes> GetMultiplicationAsync(NumberReq numberReq)
 {
     return(await _client.MultiplyAsync(numberReq));
 }