Ejemplo n.º 1
0
        public async Task Execute(IJobExecutionContext context)
        {
            try
            {
                var donations = await _db.Donations
                                .Where(d => d.CreatedAt <= HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow).AddMinutes(-5) &&
                                       d.Status == Donation.DonationStatusEnum.Pending)
                                .ToListAsync();

                foreach (var item in donations)
                {
                    item.Status           = Donation.DonationStatusEnum.Cancel;
                    _db.Entry(item).State = EntityState.Modified;
                    await _db.SaveChangesAsync();

                    HelperMethod.NotifyEmailTransaction("Transaction no " + item.Id + " is" +
                                                        item.Status, "Transaction Result",
                                                        item, "Transaction result",
                                                        "*****@*****.**");
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                Console.WriteLine(e);
            }
        }