Esempio n. 1
0
        public async Task AddNotification(string email, string operationKey, EfEnums.NotificationRequestTypeEnum type)
        {
            this.context.NotificationRequests.Add(new NotificationRequest()
            {
                Email = email,
                NotificationRequestTypeId = (int)type,
                OperationKey = operationKey
            });

            await this.context.SaveChangesAsync();
        }
Esempio n. 2
0
        public async Task <IEnumerable <NotificationRequest> > GetAndClearNotifications(EfEnums.NotificationRequestTypeEnum type, string operationKey = null)
        {
            var query = this.context.NotificationRequests
                        .AsNoTracking()
                        .Where(x => x.NotificationRequestTypeId == (int)type);

            if (operationKey != null)
            {
                query = query.Where(x => x.OperationKey == operationKey);
            }

            var results = await query.ToListAsync();

            this.context.NotificationRequests.RemoveRange(results);

            await this.context.SaveChangesAsync();

            return(results);
        }