Exemplo n.º 1
0
        public static async Task <AppraisalQuoteResponse> GetQuoteForState(AppraisalQuote request)
        {
            var fee           = Math.Round((decimal)request.StateCode[0] / 5, 2);
            var appraisalType = request.ProductType ?? "N/A";

            await Task.Delay(500);

            return(new AppraisalQuoteResponse
            {
                Notes = string.Format("That'll be {0} for {1}", fee, appraisalType),
                Fee = fee
            });
        }
Exemplo n.º 2
0
        private async Task <AppraisalQuoteResponse> GetFromCache(AppraisalQuote request)
        {
            AppraisalQuoteResponse result;

            using (var client = new RedisClient(ConfigUtils.GetAppSetting("RedisEndpoint").ToRedisEndpoint()))
            {
                result = client.As <AppraisalQuoteResponse>().GetValue("JLR-" + request.StateCode + "-appraisalPrices");
                if (result == null)
                {
                    result = await AppraisalDataLookup.GetQuoteForState(request);

                    client.Set("JLR-" + request.StateCode + "-appraisalPrices", result, DateTime.Now.AddHours(1));
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        public async Task <AppraisalQuoteResponse> Get(AppraisalQuote request)
        {
            AppraisalQuoteResponse result;
            var watch = System.Diagnostics.Stopwatch.StartNew();

            if (request.FromCache)
            {
                result = await GetFromCache(request);
            }
            else
            {
                result = await AppraisalDataLookup.GetQuoteForState(request);
            }

            Log.InfoFormat("Call returning from {0} in {1} milliseconds", request.FromCache ? "cache" : "db", watch.ElapsedMilliseconds);
            return(result);
        }