Example #1
0
        public async Task <int> LogHitCountToDb(string requestId, string cardIIN, GetCardDetailsDTO cardDetails)
        {
            var affectedRowCount = 0;

            try
            {
                //Save inquiry record to db and return no. of affected row(s)
                var requestLog = new CardInquiryLog()
                {
                    IIN         = cardIIN,
                    InquiryDate = DateTime.Now,
                    NoOfHit     = 1,
                    Status      = cardDetails != null ? "success" : "failed"
                };
                await _unitOfWork.CardInquiries.AddCardInquiry(requestLog);

                affectedRowCount = _unitOfWork.SaveChanges();
                _unitOfWork.Dispose();

                return(affectedRowCount);
            }
            catch (Exception ex)
            {
                _logger.LogError($"[InquiryCountService][LogHitCountToDb][Err] => {ex.Message} | {JsonConvert.SerializeObject(ex.InnerException)} | [requestId]=> {requestId}");
                return(affectedRowCount);
            }
        }
Example #2
0
        public async Task LogHitCountToDb_ShouldReturnNoOfRowsAffected_WhenInquiryRecordIsSaved()
        {
            //setup response
            int rowsAffected   = 1;
            var testCardIIN    = TestCards.ValidCardIIN;
            var binListAPiResp = ResponseMock.GetCardIINResp(200);
            var cardDetails    = JsonConvert.DeserializeObject <GetCardDetailsDTO>(binListAPiResp?.Content);

            var newCardInquiry = new CardInquiryLog()
            {
                IIN         = testCardIIN.ToString(),
                InquiryDate = DateTime.Now,
                NoOfHit     = 1,
                Status      = "success"
            };

            //setup File logging
            _loggerMock.Setup(x =>
                              x.LogError(It.IsAny <string>()));

            //setup repository
            _unitOfWorkMock.Setup(x =>
                                  x.CardInquiries.AddCardInquiry(newCardInquiry));

            _unitOfWorkMock.Setup(x =>
                                  x.SaveChanges())
            .Returns(rowsAffected);

            //test service method
            var rowCount = await _sut.LogHitCountToDb(It.IsAny <string>(), testCardIIN.ToString(), cardDetails);

            rowCount.Should().Be(rowsAffected);
        }
Example #3
0
        public static List<CardInquiryLog> GetListofCardInquiries(bool isEmptyList = false)
        {
            if (isEmptyList)
            {
                return new List<CardInquiryLog>() { };
            }

            var inquiries = new CardInquiryLog()
            {
                Id = 1,
                IIN = TestCards.ValidCardIIN.ToString(),
                NoOfHit = 1,
                InquiryDate = DateTime.Now,
                Status = "success"
            };
            return new List<CardInquiryLog>()
            {
                inquiries
            };
        }