Exemple #1
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
            });
        }
Exemple #2
0
        public async Task <Result <Card> > GetCardByNumberAsync(string CardNumber)
        {
            var card = await _dbContext.Set <Card>()
                       .Where(c => c.CardNumber == CardNumber)
                       .SingleOrDefaultAsync();

            if (card != null)
            {
                return(new Result <Card>()
                {
                    Code = ResultCode.Success,
                    Message = $"Card found",
                    Data = card
                });
            }
            else
            {
                return(new Result <Card>()
                {
                    Code = ResultCode.NotFound,
                    Message = $"Customer ID {CardNumber} not found !"
                });
            }
        }