Beispiel #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);
            }
        }
Beispiel #2
0
        public async Task Execute(IJobExecutionContext context)
        {
            try
            {
                var projects = await _db.Projects.Where(p => p.Status == Project.ProjectStatusEnum.Ongoing &&
                                                        p.ExpireDate <= HelperMethod.GetCurrentDateTimeWithTimeZone(DateTime.UtcNow))
                               .ToListAsync();

                foreach (var item in projects)
                {
                    if (item.CurrentFund < item.Goal)
                    {
                        item.Status           = Project.ProjectStatusEnum.Suspended;
                        _db.Entry(item).State = EntityState.Modified;
                        await _db.SaveChangesAsync();

                        await HelperMethod.FailProject(item.Id);
                    }
                    else
                    {
                        item.Status           = Project.ProjectStatusEnum.Success;
                        _db.Entry(item).State = EntityState.Modified;
                        await _db.SaveChangesAsync();

                        await HelperMethod.SuccessProject(item.Id);
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                Console.WriteLine(e);
            }
        }