Esempio n. 1
0
        //Add a feed to the feed table, and a corresponding entry in Category_Feed Table
        public bool AddFeed(Feed newFeed, Category cat)
        {
            dbMutex.WaitOne();
            bool checkfeed  = checkFeed(newFeed.FeedBaseURI, cat.CategoryID);
            bool feedexists = checkIfFeedExists(newFeed.FeedID);

            //Checks if the feed is in the database
            if (feedexists)
            {
                newFeed.SharedCount    = 0;
                newFeed.UnreadCount    = 0;
                newFeed.ViewCount      = 0;
                newFeed.FavoritedCount = 0;
                db.Feed.InsertOnSubmit(newFeed);
                db.SubmitChanges();

                Category_Feed newCat_Feed = new Category_Feed {
                    CategoryID = cat.CategoryID, FeedID = newFeed.FeedID
                };
                db.Category_Feed.InsertOnSubmit(newCat_Feed);
                db.SubmitChanges();
            }
            //If it does, but not to the category, add it to the category
            else if (checkfeed)
            {
                Category_Feed newCat_Feed = new Category_Feed {
                    CategoryID = cat.CategoryID, FeedID = newFeed.FeedID
                };
                db.Category_Feed.InsertOnSubmit(newCat_Feed);
                db.SubmitChanges();
            }
            //Else do nothing.
            dbMutex.ReleaseMutex();
            return(checkfeed || feedexists);
        }
Esempio n. 2
0
        public void AddCat_Feed(int newFeed, int cat)
        {
            Category_Feed newCat_Feed = new Category_Feed {
                CategoryID = cat, FeedID = newFeed
            };

            db.Category_Feed.InsertOnSubmit(newCat_Feed);
            db.SubmitChanges();
        }