private void CreateOrChangeContentLang(SiteContainer context, CategoryBrandItem instance, CategoryBrandItem cache, Language lang) { CategoryBrandItemLang contenttLang = null; if (cache != null) { contenttLang = context.CategoryBrandItemLang.FirstOrDefault(p => p.CategoryBrandItemId == cache.Id && p.LanguageId == lang.Id); } if (contenttLang == null) { var newPostLang = new CategoryBrandItemLang { CategoryBrandItemId = instance.Id, LanguageId = lang.Id, Title = instance.Title, Text = HttpUtility.HtmlDecode(instance.Text) }; context.AddToCategoryBrandItemLang(newPostLang); } else { contenttLang.Title = instance.Title; contenttLang.Text = HttpUtility.HtmlDecode(instance.Text); } context.SaveChanges(); }