public static ResponseResult <T> Validate <T>(
            this ResponseResult <T> responseResult,
            Func <bool> isValidDelegate,
            string errorCode,
            string error)
        {
            if (!isValidDelegate())
            {
                responseResult.AddError(errorCode, error);
            }

            return(responseResult);
        }
Exemple #2
0
        public Task <ResponseResult <QuotationResult> > GetPrice(RiskData riskData)
        {
            var responseResult = new ResponseResult <QuotationResult>();

            if (riskData.DOB == null)
            {
                responseResult.AddError(nameof(riskData.DOB), "DOB is mandatory.");
                return(Task.FromResult(responseResult));
            }

            responseResult.Value = new QuotationResult
            {
                Price = 123.45M,
                Name  = "Test Name",
                Tax   = 123.45M * 0.12M
            };

            return(Task.FromResult(responseResult));
        }
Exemple #3
0
        public Task <ResponseResult <QuotationResult> > GetPrice(RiskData riskData)
        {
            var responseResult = new ResponseResult <QuotationResult>();

            if (!(riskData.Make == "examplemake1" ||
                  riskData.Make == "examplemake2" ||
                  riskData.Make == "examplemake3"))
            {
                responseResult.AddError(nameof(riskData.Make), $"Make '{riskData.Make}' is not supported.");
                return(Task.FromResult(responseResult));
            }

            responseResult.Value = new QuotationResult
            {
                Price = 234.56M,
                Name  = "qewtrywrh",
                Tax   = 234.56M * 0.12M
            };

            return(Task.FromResult(responseResult));
        }