/// <summary> /// Called by the WCF service for each subscriber that we attempted to called /// </summary> /// <param name="notificationId">Id of the notification record</param> /// <param name="subscriber">Subscriber we attempted to contact</param> /// <param name="errorMessage">If an error occurred, this will be a non-null string with the message</param> public void CreateSubscriptionNotification(int notificationId, string subscriber, string errorMessage) { // Find the subscription id by subscriber name and notification event name // We need it to create a list of records for each subscriber that we attemped to contact using (var db = new XanoSNCEntities()) { var subscriptionDB = (from sb in db.xSubscriptions join sc in db.xSubscribers on sb.SubscriberId equals sc.Id select sb).SingleOrDefault(); if (subscriptionDB == null) throw new Exception("Subscription does not exist!"); var subscriptionNotification = new xSubscriptionNotification() { CreatedDate = DateTime.Now, NotificationError = errorMessage, SubscriptionId = subscriptionDB.Id, }; db.xSubscriptionNotifications.Add(subscriptionNotification); db.SaveChanges(); } }
public int CreateSubscriptionNotification(int notificationId, string subscriber) { using (var db = new XanoSNCEntities()) { var xSubscriber = (from s in db.xSubscribers where s.Name == subscriber select s).SingleOrDefault(); if (xSubscriber == null) { throw new Exception("Subscriber with name: " + subscriber + " does not exist."); } var subscriptionNotification = new xSubscriptionNotification() { NotificationId = notificationId, SubscriptionId = xSubscriber.Id, CreatedDate = DateTime.Now }; db.xSubscriptionNotifications.Add(subscriptionNotification); db.SaveChanges(); return subscriptionNotification.Id; } }