Пример #1
0
 public bool AddNotifcation(Notification notification)
 {
     using (var ctx = new AbsentiaDbContext())
     {
         ctx.Notifications.Add(notification);
         return(ctx.SaveChanges() > 0);
     }
 }
Пример #2
0
 public bool AddSubscription(string username, Subscription subscription)
 {
     using (var ctx = new AbsentiaDbContext())
     {
         var user = ctx.Users.Single(x => x.UserName.Equals(username));
         user.Subscriptions.Add(subscription);
         return(ctx.SaveChanges() > 0);
     }
 }
Пример #3
0
 public bool RemoveNotification(int notificationId)
 {
     using (var ctx = new AbsentiaDbContext())
     {
         var ns = ctx.Notifications;
         foreach (var notification in ns)
         {
             notification.ProcessingResult = null;
         }
         return(ctx.SaveChanges() > 0);
     }
 }
Пример #4
0
 public void AddSubscriptionAttempt(string username, bool success, string message, DateTime attemptTime)
 {
     using (var ctx = new AbsentiaDbContext())
     {
         ctx.SubscriptionAttempts.Add(new SubscriptionAttempt
         {
             UserName    = username,
             Message     = message,
             AttemptTime = attemptTime
         });
         ctx.SaveChanges();
     }
 }
Пример #5
0
        public void UpdateSubscriptionExpiry(string subscriptionId, DateTime subscriptionExpiryUtc)
        {
            using (var ctx = new AbsentiaDbContext())
            {
                Subscription pr = new Subscription()
                {
                    Id = subscriptionId,
                };

                ctx.Subscriptions.Attach(pr);
                pr.ExpirationDateTime = subscriptionExpiryUtc;

                ctx.SaveChanges();
            }
        }
Пример #6
0
        public void SetNotificationProcessingResult(int notificationId, bool result, string message)
        {
            using (var ctx = new AbsentiaDbContext())
            {
                Notification pr = new Notification()
                {
                    NotificationId = notificationId,
                };

                ctx.Notifications.Attach(pr);
                pr.ProcessingResult             = result;
                pr.ProcessingMessage            = message;
                pr.NotificationProcessedTimeUtc = DateTime.UtcNow;

                ctx.SaveChanges();
            }
        }