コード例 #1
0
        public async Task <ActionResult <CalculatorResultViewModel> > Subtract(Guid?id, decimal?value, CancellationToken cancellationToken)
        {
            if (!value.HasValue)
            {
                return(BadRequest("Must provide value"));
            }

            return(Ok(await _subtractionService.Subtract(id, value.Value, cancellationToken)));
        }
コード例 #2
0
        public int ProcessOperation(int value1, int value2, Operation operation)
        {
            switch (operation)
            {
            case Operation.Sum:
                return(_sumService.Sum(value1, value2));

            case Operation.Subtract:
                return(_subtractionService.Subtract(value1, value2));
            }

            throw new InvalidOperationException();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            var httpClient = new HttpClient();

            httpClient.BaseAddress = new Uri("http://localhost:5024");

            ISubtractionService subtractionService = httpClient.GetProxy <ISubtractionService>();
            IAdditionService    additionService    = httpClient.GetProxy <IAdditionService>();

            var addResult      = additionService.Add(2, 3);
            var subtractResult = subtractionService.Subtract(2, 3);

            Console.WriteLine($"2 + 3 = {addResult}");
            Console.WriteLine($"2 - 3 = {subtractResult}");
        }
コード例 #4
0
 public int Subtract(int x, int y)
 {
     return(subtraction.Subtract(x, y));
 }