public async Task <IActionResult> PutFund(string id, Fund fund)
        {
            if (id != fund.FundName)
            {
                return(BadRequest());
            }

            _context.Entry(fund).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FundExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #2
0
 public async Task<IActionResult> Create([Bind("Id,code,name,value,UpdateDate,ChangeInDay,ChangeInWeek,ChangeInMonth")] Fund fund)
 {
     if (ModelState.IsValid)
     {
         _context.Add(fund);
         await _context.SaveChangesAsync();
         return RedirectToAction(nameof(Index));
     }
     return View(fund);
 }
Exemple #3
0
        protected override async Task ProcessEvent(DonorTransactionSourceEvent @event)
        {
            var existing = _context
                           .DonorTransactionSources
                           .SingleOrDefault(x => x.TransactionSourceIdentifier == @event.TransactionSourceIdentifier);

            if (existing == null)
            {
                return;
            }

            existing.IsDeleted = true;
            await _context.SaveChangesAsync();
        }
        protected override async Task ProcessEvent(DonorTransactionSourceEvent @event)
        {
            var existing = _context
                           .DonorTransactionSources
                           .SingleOrDefault(x => x.TransactionSourceIdentifier == @event.TransactionSourceIdentifier);

            if (existing != null)
            {
                return;
            }

            var donorTransactionSource = new DonorTransactionSource
            {
                TransactionSourceIdentifier = @event.TransactionSourceIdentifier,
                FinancialInstitution        = @event.FinancialInstitution,
                Identifier = @event.Identifier
            };

            _context.DonorTransactionSources.Add(donorTransactionSource);
            await _context.SaveChangesAsync();
        }
        protected override async Task ProcessEvent(TransactionEvent @event)
        {
            if (HasProcessedTransaction(@event))
            {
                return;
            }

            var donorTransactionSource = GetDonorTransactionSource(@event);

            if (donorTransactionSource == null)
            {
                return;
            }

            var merchant = GetOrCreateMerchant(@event);

            var transaction = new Transaction
            {
                Amount   = @event.Amount,
                Currency = @event.Currency,
                ExternalTransactionIdentifier = @event.TransactionIdentifier,
                ReceivedDateTimeUtc           = DateTime.UtcNow,
                TransactionDateTimeUtc        = @event.TransactionDateTimeUtc,
                TransactionIdentifier         = Guid.NewGuid(),
                Merchant                 = merchant,
                MerchantId               = merchant.Id,
                DonorTransactionSource   = donorTransactionSource,
                DonorTransactionSourceId = donorTransactionSource.Id
            };

            _fundContext.Transactions.Add(transaction);
            await _fundContext.SaveChangesAsync();

            var transactionIntegrationEvent = ToTransactionIntegrationEvent(transaction);
            var integrationEvent            = new IntegrationEvent <TransactionIntegrationEvent>(ServiceNames.TransactionProcessor.ToString(), EventNames.NewTransaction.ToString(), transactionIntegrationEvent);

            _queue.Post(integrationEvent);
        }
 public async Task <bool> SaveChangesAsync()
 {
     return(await dbContext.SaveChangesAsync() > 0);
 }