Example #1
0
        public PageWord(String page, string word, int location)
        {
            using (PageDBContext pc = new PageDBContext())
            {
                Page temp_page = null;
                Word temp_word = null;
                PageWord page_word_query = null;

                temp_page = new Page(page);
                temp_word = new Word(word);

                try
                {
                    page_word_query = pc.PageWord.First(pw => pw.WordID == temp_word.WordID && pw.PageID == temp_page.PageID && Location == location);
                }
                catch (InvalidOperationException iex)
                { }

                if (page_word_query == null)
                {
                    this.Location = location;
                    this.PageID = temp_page.PageID;
                    this.WordID = temp_word.WordID;
                    pc.PageWord.Add(this);
                    pc.SaveChanges();
                }
                else
                {
                    this.WordID = page_word_query.WordID;
                    this.PageWordID = page_word_query.PageWordID;
                    this.PageID = page_word_query.PageID;
                    this.Location = page_word_query.Location;
                }
            }
        }
Example #2
0
        public Link(Page from, Page to)
        {
            using (PageDBContext pc = new PageDBContext())
            {
                Link query = null;
                try
                {
                    query = pc.Link.First(l => l.FromPage == from.PageID && l.ToPage == to.PageID);
                }
                catch (InvalidOperationException iex)
                { }

                if (query == null)
                {
                    this.FromPage = from.PageID;
                    this.ToPage = to.PageID;
                    pc.Link.Add(this);
                    pc.SaveChanges();
                }
                else
                {
                    this.FromPage = query.FromPage;
                    this.ToPage = query.ToPage;
                    this.LinkID = query.LinkID;
                }
            }
        }
Example #3
0
        public Word(String word)
        {
            using (PageDBContext pc = new PageDBContext())
            {
                Word query = null;
                try
                {
                    query = pc.Words.First(w => w.WordValue == word);
                }
                catch (InvalidOperationException iex)
                { }

                if (query == null)
                {
                    WordValue = word;
                    WordStem = Word.Stem(word);
                    pc.Words.Add(this);
                    pc.SaveChanges();
                }
                else
                {
                    this.WordID = query.WordID;
                    this.WordValue = query.WordValue;
                    this.WordStem = query.WordStem;
                }
            }
        }
Example #4
0
        public Page(string URL)
        {
            using (PageDBContext pc = new PageDBContext())
            {
                Page query = null;
                try
                {
                    query = pc.Pages.First(p => p.Url == URL);
                }
                catch (InvalidOperationException iex)
                { }

                if (query == null)
                {
                    this.Url = URL;
                    pc.Pages.Add(this);
                    pc.SaveChanges();
                }
                else
                {
                    this.PageID = query.PageID;
                    this.Url = query.Url;
                }
            }
        }