Exemple #1
0
 public async Task <IActionResult> Create([Bind("Id,userSenderId,organizationReceiverId,amount")] Payment payment)
 {
     if (ModelState.IsValid)
     {
         payment.Id = Guid.NewGuid();
         ProcessPayment p      = new ProcessPayment();
         bool           result = p.DoPayment(payment, _context);
         if (result == true)
         {
             return(RedirectToAction("", "Organizations"));
         }
         //_context.Add(payment);
         //await _context.SaveChangesAsync();
     }
     return(View(payment));
 }
Exemple #2
0
        public void UnitTest_MoneyTransferringInvalid_CheckOrganizationAmount()
        {
            mockDB();
            var     userTransferring      = _dbContext.user.FirstOrDefault();
            var     hisCard               = _dbContext.card.Where(c => c.Id.ToString().Equals(userTransferring.creditCardId.ToString())).First();
            var     organizationReceiving = _dbContext.organization.FirstOrDefault();
            var     theirCard             = _dbContext.card.Where(c => c.Id.ToString().Equals(organizationReceiving.creditCardNumber.ToString())).First();
            var     amountBeforeUser      = hisCard.amount;
            var     amountBeforeOrga      = theirCard.amount;
            Payment payment               = new Payment();

            payment.amount = 99999;
            payment.organizationReceiverId = organizationReceiving.Id;
            payment.userSenderId           = userTransferring.Id;
            ProcessPayment p        = new ProcessPayment();
            var            possible = p.DoPayment(payment, _dbContext);

            Assert.Equal(amountBeforeOrga, theirCard.amount);
        }