Example #1
0
 public void AddSubscribedWebsite(string userName, string websiteLink, string websiteOwner)
 {
     if (!String.IsNullOrEmpty(websiteLink))
     {
         dal.AddSubscribedWebsite(userName, ParseLink(websiteLink));
         var bl = new MonitoredWebsitesBL();
         var website = new MonitoredWebsite
         {
             Id = websiteLink,
             Title = websiteOwner
         };
         bl.SaveMonitoredWebsite(website);
     }
 }
        public void ShouldInsertWebsite()
        {
            var monitoredWebsitesBL = new MonitoredWebsitesBL();
            var website = new MonitoredWebsite
                              {
                                  Title = "Tehnologii Web",
                                  Owner = "busaco",
                                  WebsiteSubjectId = "2",
                                  Id = "http://info.uaic.ro/~busaco/"
                              };
            monitoredWebsitesBL.SaveMonitoredWebsite(website);

            website = new MonitoredWebsite
            {
                Title = "Arhitectura Calculatoarelor",
                Owner = "rvlad",
                WebsiteSubjectId = "3",
                Id = "http://info.uaic.ro/~rvlad/"
            };

            monitoredWebsitesBL.SaveMonitoredWebsite(website);
        }
        public void SaveMonitoredWebsite(MonitoredWebsite website)
        {
            MonitoredWebsitesCollection.Collection.Save(website);
            var notificationsDAL = new NotificationsDAL();

            var notification = new MonitoredWebsiteNotification
                                                            {
                                                                NotificationType =
                                                                    NotificationTypes.MonitoredWebsitesNotification,
                                                                WebsiteId = website.Id,
                                                                SentDate = DateTime.Now,
                                                                Title =
                                                                    String.Format(
                                                                        "Website at {0} has changed its content.",
                                                                        website.Id)
                                                            };

            notificationsDAL.InsertNotification(notification);

            var usersDAL = new UsersDAL();
            var allStudents = usersDAL.GetAllStudents();

            if (allStudents != null)
                foreach (var student in allStudents)
                {
                    if (student.SubscribedWebsites.Find(delegate(string gr)
                                                            {
                                                                return gr == website.Id;
                                                            }

                    ).Any())
                    {
                        student.Notifications.Add(new UserNotification
                        {
                            NotificationId = notification._id.ToString(),
                            NotificationType = NotificationTypes.MonitoredWebsitesNotification,
                            UserSolved = false
                        });
                    }
                    usersDAL.SaveStudent(student);
                }
        }
 public void InsertWebsite(MonitoredWebsite website)
 {
     MonitoredWebsitesCollection.Collection.Insert(website);
 }
 public void SaveMonitoredWebsite(MonitoredWebsite website)
 {
     website.HashedContent = Monitor.GetMD5Hash(website.Id);
     dal.SaveMonitoredWebsite(website);
 }
 public void InsertWebsite(MonitoredWebsite website)
 {
     dal.InsertWebsite(website);
 }