Esempio n. 1
0
 public string GetTeacherNotificationsAsXml(string username, int count)
 {
     var bl = new NotificationsBL();
     return bl.GetUserNotificationsAsXml(username, count, UserTypes.Teacher);
 }
Esempio n. 2
0
        private string GetXmlFromNotifications(List<UserNotification> list)
        {
            var document = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
            var notifications = new XElement("notifications");
            notifications.Add(new XAttribute("count", list.Count));
            var notificationsBL = new NotificationsBL();
            foreach (UserNotification userNotification in list)
            {
                var notificationElement = new XElement("notification");
                notificationElement.Add(new XElement("solved", userNotification.UserSolved));

                var notificationDetails = new XElement("details");
                notificationDetails.Add(new XAttribute("type", userNotification.NotificationType));
                Notification notification = null;
                switch (userNotification.NotificationType)
                {
                    case NotificationTypes.FeedNotification:

                        var feedNotification =
                            (FeedNotification)
                            notificationsBL.GetNotification(userNotification.NotificationId, NotificationTypes.FeedNotification);
                        if (feedNotification != null)
                        {
                            var feedbl = new FeedsBL();
                            Feed feed = feedbl.GetFeed(feedNotification.FeedId);
                            if (feed != null)
                            {
                                notificationDetails.Add(new XElement("message", feed.Message));
                                notificationDetails.Add(new XElement("sender", feed.Sender));
                            }
                            notification = feedNotification;
                        }
                        break;
                    case NotificationTypes.TimetableNotification:
                        var timetableNotification =
                            (TimetableNotification)
                            notificationsBL.GetNotification(userNotification.NotificationId, NotificationTypes.TimetableNotification);
                        if (timetableNotification != null)
                        {
                            notificationDetails.Add(new XElement("timetableNotificationType",
                                                                 timetableNotification.TimetableNotificationType));
                            notificationDetails.Add(new XElement("dayOfWeek", timetableNotification.Day));
                            notificationDetails.Add(new XElement("typeOfClass",
                                                                 timetableNotification.ModifiedItem.TypeOfClass));
                            notificationDetails.Add(new XElement("className",
                                                                 timetableNotification.ModifiedItem.ClassName));
                            notificationDetails.Add(new XElement("startTime",
                                                                 timetableNotification.ModifiedItem.StartTime));
                            notificationDetails.Add(new XElement("endTime",
                                                                 timetableNotification.ModifiedItem.EndTime));
                            notification = timetableNotification;
                        }
                        break;
                    case NotificationTypes.MonitoredWebsitesNotification:
                        var websiteNotification =
                            (MonitoredWebsiteNotification)notificationsBL.GetNotification(userNotification.NotificationId, NotificationTypes.MonitoredWebsitesNotification);
                        if (websiteNotification != null)
                        {
                            notificationDetails.Add(new XElement("websiteLink", websiteNotification.WebsiteId));
                            notification = websiteNotification;
                        }
                        break;
                }
                if (notification != null)
                {
                    notificationElement.Add(new XElement("dateSent", notification.SentDate.ToString()));
                    notificationElement.Add(new XElement("title", notification.Title));
                }
                notificationElement.Add(notificationDetails);

                notifications.Add(notificationElement);
            }
            document.Add(notifications);
            return document.ToString();
        }
Esempio n. 3
0
 public void SolveUserNotification(string notificationId, string username)
 {
     var bl = new NotificationsBL();
     bl.SolveNotification(notificationId, username);
 }