Ejemplo n.º 1
0
        public async Task <Bin> GetBinDetails(string bin)
        {
            logger.LogInformation($"Getting bin details for {bin}");

            //get bin details from cache if it exists
            var binFromCache = cacheManager.Get(bin);

            Bin binDetails = new Bin();

            if (!string.IsNullOrEmpty(binFromCache))
            {
                binDetails = JsonConvert.DeserializeObject <Bin>(binFromCache);
            }
            else
            {
                binDetails = await binlistService.GetBinDetails(bin);

                var binDetailsString = JsonConvert.SerializeObject(binDetails);

                cacheManager.Set(bin, binDetailsString);
            }


            await IncrementCount(bin);

            logger.LogInformation($"bin details response {JsonConvert.SerializeObject(binDetails)}");

            return(binDetails);
        }
        public async Task <IActionResult> GetBinDetails([FromQuery] BinlistRequestModel binlistRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            return(Ok(await _binlistService.GetBinDetails(binlistRequest.cardIin)));
        }