private void CreateOrChangeContentLang(SiteContainer context, Brand instance, Brand cache, Language lang) { BrandLang contenttLang = null; if (cache != null) { contenttLang = context.BrandLang.FirstOrDefault(p => p.BrandId == cache.Id && p.LanguageId == lang.Id); } if (contenttLang == null) { var newPostLang = new BrandLang { BrandId = instance.Id, LanguageId = lang.Id, Title = instance.Title, Description = instance.Description }; context.AddToBrandLang(newPostLang); } else { contenttLang.Title = instance.Title; contenttLang.Description = instance.Description; } context.SaveChanges(); }