コード例 #1
0
        private async Task CreateCardNotificationAsync(DbContextOptions <MemCheckDbContext> db, Guid subscriberId, Guid cardId)
        {
            using var dbContext = new MemCheckDbContext(db);
            var notif = new CardNotificationSubscription();

            notif.CardId = cardId;
            notif.UserId = subscriberId;
            dbContext.CardNotifications.Add(notif);
            await dbContext.SaveChangesAsync();
        }
コード例 #2
0
        private async Task CreateCardNotificationAsync(DbContextOptions <MemCheckDbContext> testDB, Guid subscriberId, Guid cardId, DateTime lastNotificationDate)
        {
            using var dbContext = new MemCheckDbContext(testDB);
            var notif = new CardNotificationSubscription();

            notif.CardId = cardId;
            notif.UserId = subscriberId;
            notif.LastNotificationUtcDate = lastNotificationDate;
            dbContext.CardNotifications.Add(notif);
            await dbContext.SaveChangesAsync();
        }
コード例 #3
0
        public static async Task CreateAsync(DbContextOptions <MemCheckDbContext> testDB, Guid subscriberId, Guid cardId, DateTime?lastNotificationDate = null)
        {
            using var dbContext = new MemCheckDbContext(testDB);
            var notif = new CardNotificationSubscription {
                CardId = cardId, UserId = subscriberId
            };

            if (lastNotificationDate != null)
            {
                notif.LastNotificationUtcDate = lastNotificationDate.Value;
            }
            dbContext.CardNotifications.Add(notif);
            await dbContext.SaveChangesAsync();
        }
コード例 #4
0
        public async Task RunAsync(Request request)
        {
            request.CheckValidity();

            foreach (var cardId in request.CardIds)
            {
                if (!dbContext.CardNotifications.Where(notif => notif.UserId == request.UserId && notif.CardId == cardId).Any())
                {
                    CardNotificationSubscription notif = new CardNotificationSubscription
                    {
                        CardId = cardId,
                        UserId = request.UserId,
                        RegistrationUtcDate     = DateTime.UtcNow,
                        RegistrationMethod      = CardNotificationSubscription.CardNotificationRegistrationMethod_ExplicitByUser,
                        LastNotificationUtcDate = DateTime.UtcNow
                    };
                    dbContext.CardNotifications.Add(notif);
                }
            }

            await dbContext.SaveChangesAsync();
        }