public ActionResult <CalculatorValue> Subtract([FromBody] CalculatorSubtractPayload payload) { if (_validator.ValidateNull(payload, out var result)) { return(result); } return(Ok(_calculator.Subtract(payload.Values, payload.Minuend))); }
public bool ValidateNull(CalculatorSubtractPayload payload, out ActionResult <CalculatorValue> result) { if (_nullValidator.Validate(payload.Minuend)) { result = new BadRequestObjectResult(string.Format(ErrorMessages.NULL_VALUE_TEMPLATE, nameof(payload.Minuend))); return(true); } foreach (var vaues in payload.Values) { if (_nullValidator.Validate(vaues)) { result = new BadRequestObjectResult(ErrorMessages.NULL_VALUE); return(true); } } result = null; return(false); }