Пример #1
0
        private void CreateOrChangeContentLang(SiteContext context, Article instance, Article cache, Language lang)
        {

            ArticleLang productLang = null;
            if (cache != null)
            {
                productLang = context.ArticleLangs.FirstOrDefault(p => p.ArticleId == cache.Id && p.LanguageId == lang.Id);
            }
            if (productLang == null)
            {
                var newPostLang = new ArticleLang
                {
                    ArticleId = instance.Id,
                    LanguageId = lang.Id,
                    Title = instance.Title,
                    Description = instance.Description
                };
                context.ArticleLangs.Add(newPostLang);
            }
            else
            {
                productLang.Title = instance.Title;
                productLang.Description = instance.Description;
            }
            context.SaveChanges();

        }
Пример #2
0
 private void SetLang(ArticleLang postLang)
 {
     Title = postLang.Title;
     Description = postLang.Description;
 }