示例#1
0
        public async Task <SumResponseDto> Addition(SumDto sum, string trackingId)
        {
            var result   = sum.Addends.Sum();
            var response = new SumResponseDto {
                Sum = result
            };

            await _journal.AddJournalOperation(EnumOperationsType.Sum, sum, response, trackingId);

            return(response);
        }
        public async Task <SumResponseDto> Add([FromHeader(Name = "X-Evi-TrackingId")] string trackingId, [FromBody] SumDto add)
        {
            _loggerManager.LogInfo("Call 'Add' post method on CalculatorController");

            if (add.Addends == null)
            {
                _loggerManager.LogError("BadRequestException on calls 'Add' post method on CalculatorController");
                throw new BadRequestException("Unable to process request: Add");
            }

            try
            {
                var result = await _calculator.Addition(add, trackingId);

                return(result);
            }
            catch (System.Exception ex)
            {
                _loggerManager.LogError("InternalErrorException on calls 'Add' post method on CalculatorController", ex);
                throw new InternalErrorException("An unexpected error condition was triggered which made impossible to fulfill the request. Please try again later.");
            }
        }