private void CreateOrChangeContentLang(SiteContainer context, BrandGroupItem instance, BrandGroupItem cache, Language lang) { BrandGroupItemLang contenttLang = null; if (cache != null) { contenttLang = context.BrandGroupItemLang.FirstOrDefault(p => p.BrandGroupItemId == cache.Id && p.LanguageId == lang.Id); } if (contenttLang == null) { var newPostLang = new BrandGroupItemLang { BrandGroupItemId = instance.Id, LanguageId = lang.Id, Text = instance.Text }; context.AddToBrandGroupItemLang(newPostLang); } else { contenttLang.Text = instance.Text; } context.SaveChanges(); }