public void RemoveNotification(string notificationId) { if (string.IsNullOrEmpty(notificationId)) { return; } var notifyRepo = new NotificationsRepository(); if (!notifyRepo.Init()) { return; } var name = Context.User.Identity.Name; notifyRepo.RemoveNotification(name, notificationId); }
/// <summary> /// Removes the old sent notifications. /// </summary> /// <param name="userEmail">The user email.</param> /// <param name="sentNotifications">The sent notifications.</param> public static void RemoveOldSentNotifications(string userEmail, List <NotificationModel> sentNotifications, NotificationsRepository sentNotifyRepo) { int daysOld = 30; var timeSpan = TimeSpan.FromDays(daysOld); var dateTimeOffset = DateTime.Now.Subtract(timeSpan); foreach (var sentNotification in sentNotifications) { // Remove connection if older that 'dateTimeOffset' if (sentNotification.Timestamp.DateTime <= dateTimeOffset) { sentNotifyRepo.RemoveNotification(sentNotification.PartitionKey, sentNotification.RowKey); } } }