Exemplo n.º 1
0
        public ActionResult Add(FormCollection formCollection)
        {
            string feedUrl = formCollection["Url"];
            XmlDocument xmlDoc = FeedLoader.LoadXML(feedUrl);
            Feed feed = FeedService.CreateFeedFromXmlDoc(xmlDoc, HttpContext.User.Identity.Name);

            if (Request.IsAjaxRequest())
            {
                return Json(new { success = (feed != null) });
            }
            else
            {
                if (feed != null)
                {
                    return RedirectToAction("Index");
                }
                else
                {
                    feed = new Feed()
                    {
                        Url = feedUrl
                    };
                    return View(feed);
                }
            }
        }
Exemplo n.º 2
0
 public Feed Save(Feed feed)
 {
     var existingFeed = GetUsersFeed(feed.FeedId, feed.UserName);
     if (existingFeed == null)
     {
         feed = Create(feed);
     }
     else
     {
         feed = Update(existingFeed, feed);
     }
     return feed;
 }
Exemplo n.º 3
0
 public Feed ReadFeedDetails()
 {
     XmlNode node = XmlDoc.SelectSingleNode(headerSelector, namespaceManager);
     if (node != null)
     {
         Feed feed = new Feed();
         feed.Name = ParseNode(node, nameSelector, "Unknown Feed");
         return feed;
     }
     else
     {
         return null;
     }
 }
Exemplo n.º 4
0
        public void Save_New_Feed_Should_Increase_Total_Feeds_By_1()
        {
            // Arrange
            FeedService feedService = new FeedService(new FakeFeedRepository());
            Feed newFeed = new Feed()
            {
                Name = "New Feed",
                UserName = "******",
                Url = "http://www.example.com/feed/"
            };

            // Act
            feedService.Save(newFeed);
            var feeds = feedService.GetUsersFeeds("jammus");

            // Assert
            Assert.AreEqual(6, feeds.Count);
        }
Exemplo n.º 5
0
 public FeedReaderViewModel()
 {
     Feeds = new List<Feed>();
     NewsItems = new List<NewsItem>();
     NewFeed = new Feed();
 }
Exemplo n.º 6
0
 public void Delete(Feed feed)
 {
     db.Feeds.DeleteOnSubmit(feed);
 }
Exemplo n.º 7
0
 public void Add(Feed feed)
 {
     db.Feeds.InsertOnSubmit(feed);
 }
Exemplo n.º 8
0
 private Feed Update(Feed existingFeed, Feed feed)
 {
     existingFeed.Name = feed.Name;
     existingFeed.Url = feed.Url;
     FeedRepository.Save();
     return existingFeed;
 }
Exemplo n.º 9
0
 private Feed Create(Feed feed)
 {
     FeedRepository.Add(feed);
     FeedRepository.Save();
     return feed;
 }
Exemplo n.º 10
0
 public void Delete(Feed feed)
 {
     FeedRepository.Delete(feed);
     FeedRepository.Save();
 }
Exemplo n.º 11
0
 public void Delete(Feed feed)
 {
     db.Remove(feed);
 }
Exemplo n.º 12
0
 public void Add(Feed feed)
 {
     feed.FeedId = db.Max(f => f.FeedId) + 1;
     db.Add(feed);
 }