예제 #1
0
        public ArticleDecorator(WebArticle article, Boolean readFromDatabase = true)
        {
            this.article = article;

            if (readFromDatabase)
            {
                ReadArticleElementsFromDatabase(article);
            }
        }
예제 #2
0
        private void ReadArticleElementsFromDatabase(WebArticle article)
        {
            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                var allElements = from e in db.LangElements
                                  from w in db.WebArticleElements
                                  where e.ID == w.LangElementId && w.WebArticleId == article.ID
                                  select e;


                var userElements = from u in db.UserLangElements
                                   from w in db.WebArticleElements
                                   where u.LangElementId == w.LangElementId && w.WebArticleId == article.ID
                                   select u;


                foreach (var e in userElements.ToList <UserLangElement>())
                {
                    try
                    {
                        dicUser.Add(e.LangElementId, e);
                    }
                    catch (ArgumentException x)
                    {
                    }
                }

                foreach (var e in allElements.ToList <LangElement>())
                {
                    try
                    {
                        dic.Add(e.Value, e);
                    }
                    catch (ArgumentException x)
                    {
                    }
                }
            }
        }