public void ShouldInsertFeeds() { var bl = new FeedsBL(); var feed = new Feed { Sender = "busaco", Message = "It started raining.", PublishDate = new DateTime(2012, 2, 2), ReceiverGroups = new List<string> { "688936cd-b6ff-450a-b2ea-80573362e6de", "c920f326-5035-44d3-bd2f-690e2f831f1c" } }; bl.InsertFeed(feed); feed = new Feed { Sender = "rvlad", Faculty = "info.uaic.ro", Message = "It started raining.", PublishDate = new DateTime(2012, 2, 2), ReceiverGroups = new List<string> { "0f44bd29-26ee-4c50-a14f-0e641e1af8c8", "400e8981-feb5-4291-aa61-3044ff52d5a6" } }; bl.InsertFeed(feed); // list = bl.GetFeedsForGroup("info.uaic.ro", "asfasgasgasg"); // if (list == null) Assert.Fail(); // Assert.AreEqual(length + 2, list.Count); }
private static void CreateHtmlFromFeed(Feed feed) { string savePath = helper.SelectSaveLocation("Html document|*.html"); var documentWriter = new StreamWriter( savePath, append: false, encoding: System.Text.Encoding.UTF8); using (documentWriter) { using (var htmlWriter = new HtmlTextWriter(documentWriter)) { // The document generated is partial html piece without head and body // Imagine trying to add the <html> <head> <title> <body> and their closing // tags with this load of crap... no thank you htmlWriter.RenderBeginTag(HtmlTextWriterTag.H2); htmlWriter.Write("Videos from "); htmlWriter.AddAttribute(HtmlTextWriterAttribute.Href, feed.Author.Uri); htmlWriter.RenderBeginTag(HtmlTextWriterTag.A); htmlWriter.Write(feed.Author.Name); htmlWriter.RenderEndTag(); htmlWriter.RenderEndTag(); htmlWriter.WriteLine(); htmlWriter.AddAttribute(HtmlTextWriterAttribute.Id, "videos"); htmlWriter.RenderBeginTag("section"); foreach (var entry in feed.Entries) { htmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "video"); htmlWriter.AddStyleAttribute(HtmlTextWriterStyle.Display, "inline-block"); htmlWriter.AddStyleAttribute(HtmlTextWriterStyle.PaddingLeft, "10px"); htmlWriter.RenderBeginTag("article"); htmlWriter.RenderBeginTag(HtmlTextWriterTag.H3); htmlWriter.AddAttribute(HtmlTextWriterAttribute.Href, entry.Link.Href); htmlWriter.RenderBeginTag(HtmlTextWriterTag.A); htmlWriter.Write(entry.Title); htmlWriter.RenderEndTag(); htmlWriter.RenderEndTag(); htmlWriter.WriteLine(); htmlWriter.AddAttribute( HtmlTextWriterAttribute.Src, entry.MediaGroup.Content.Url); htmlWriter.AddAttribute( HtmlTextWriterAttribute.Width , entry.MediaGroup.Thumbnail.Width.ToString()); htmlWriter.RenderBeginTag(HtmlTextWriterTag.Iframe); htmlWriter.RenderBeginTag(HtmlTextWriterTag.P); htmlWriter.Write("Your browser does not support iframes."); htmlWriter.RenderEndTag(); htmlWriter.RenderEndTag(); htmlWriter.WriteLine(); htmlWriter.RenderEndTag(); htmlWriter.WriteLine(); } htmlWriter.RenderEndTag(); htmlWriter.WriteLine(); } } }
public void InsertFeed(Feed feed) { FeedsCollection.Collection.Insert<Feed>(feed); var notificationsDAL = new NotificationsDAL(); var notification = new FeedNotification { FeedId = feed._id.ToString(), NotificationType = NotificationTypes.FeedNotification, SentDate = DateTime.Now, Title = String.Format("{0} has posted a message.", feed.Sender) }; notificationsDAL.InsertNotification(notification); var usersDAL = new UsersDAL(); var allStudents = usersDAL.GetAllStudents(); if (allStudents != null) foreach (var student in allStudents) { if(student.SubscribedGroups.Find(delegate(string gr) { foreach (var receiverGroup in feed.ReceiverGroups) { if (gr == receiverGroup) return true; } return false; } ).Any()) { student.Notifications.Add(new UserNotification { NotificationId = notification._id.ToString(), NotificationType = NotificationTypes.FeedNotification, UserSolved = false }); } usersDAL.SaveStudent(student); } }
public void InsertFeed(Feed feed) { dal.InsertFeed(feed); }