Ejemplo n.º 1
0
        public ActionResult <CalculatorValue> ResolveIncludingBand([FromBody] BandResolverPayload payload)
        {
            if (_bandValidator.Validate(payload, out var validationResult))
            {
                return(validationResult);
            }

            IBandResolver <CalculatorValue> resolver = new IncludingBandResolver(payload.Bands);
            var result = resolver.Resolve(payload.ValueToResolve);

            result.CorrelationId = payload.CorrelationId;
            return(Ok(result));
        }
Ejemplo n.º 2
0
        public bool Validate(BandResolverPayload payload, out ActionResult <CalculatorValue> result)
        {
            if (payload == null)
            {
                result = new BadRequestObjectResult(ErrorMessages.NULL_PAYLOAD);
                return(true);
            }

            if (_nullBandValidator.Validate(payload.Bands))
            {
                result = new BadRequestObjectResult(ErrorMessages.NULL_BAND);
                return(true);
            }

            if (_nullValidator.Validate(payload.ValueToResolve))
            {
                result = new BadRequestObjectResult(string.Format(ErrorMessages.NULL_VALUE_TEMPLATE, nameof(payload.ValueToResolve)));
                return(true);
            }

            result = null;
            return(false);
        }