예제 #1
0
        public async Task <Limit> UpdateLimitAsync_Success()
        {
            var options = new Services.Options.CardLimitOptions()
            {
                CardNumber       = "2222333344445555",
                AvailableBalance = 100,
                TrsansactionType = CardTransactionType.CardPresent
            };

            var result = await _limit.UpdateCardLimitAsync(options);

            Assert.Equal(ResultCode.Success, result.Code);
            Assert.Equal(options.CardNumber, result.Data.CardNumber);

            return(result.Data);
        }
예제 #2
0
        public async Task <Result <Limit> > GetBalanceByCardNumber(string CardNumbre)
        {
            var options = new Services.Options.CardLimitOptions()
            {
                CardNumber       = CardNumbre,
                AvailableBalance = 0
            };

            var result = await _cardService.CardExists(CardNumbre);

            if (result.Data == false)
            {
                return(new Result <Limit>()
                {
                    Code = result.Code,
                    Message = result.Message
                });
            }

            var limit = _dbContext.Set <Limit>()
                        .Where(l => l.CardNumber == options.CardNumber)
                        .Where(l => l.TrsansactionType == CardTransactionType.ECommerce)
                        .SingleOrDefault();

            var limit2 = _dbContext.Set <Limit>()
                         .Where(l => l.CardNumber == options.CardNumber)
                         .Where(l => l.TrsansactionType == CardTransactionType.CardPresent)
                         .SingleOrDefault();

            limit.AvailableBalance = limit.AvailableBalance + limit2.AvailableBalance;

            return(new Result <Limit>()
            {
                Code = ResultCode.Success,
                Message = "Balance found",
                Data = limit
            });
        }
예제 #3
0
        public async Task <Limit> Add_New_Limit2_Success()
        {
            var options = new Services.Options.CardLimitOptions()
            {
                CardNumber       = "1111222233334444",
                AvailableBalance = Constants.AmountLimits.ECommerce,
                TrsansactionType = CardTransactionType.ECommerce
            };

            var limit = (await _limit.RegisterCardLimitAsync(options))?.Data;

            Assert.NotNull(limit);

            var savedLimit = _dbContext.Set <Limit>()
                             .Where(c => c.ID == limit.ID)
                             .SingleOrDefault();

            Assert.NotNull(savedLimit);
            Assert.Equal(options.CardNumber, savedLimit.CardNumber);
            Assert.Equal(options.AvailableBalance, savedLimit.AvailableBalance);
            Assert.Equal(options.TrsansactionType, savedLimit.TrsansactionType);

            return(limit);
        }