public void Localize(Models.HtmlBlock o, Models.Site targetSite) { var htmlBlock = Get(o); var entity = new HtmlBlockEntity(htmlBlock); entity.SiteName = targetSite.FullName; var dbContext = SiteDbContext.CreateDbContext(); dbContext.HtmlBlocks.Add(entity); dbContext.SaveChanges(); }
private void InsertOrUpdate(Models.HtmlBlock @new, Models.HtmlBlock old) { var dbContext = SiteDbContext.CreateDbContext(); var entity = dbContext.HtmlBlocks .Where(it => it.SiteName == @new.Site.FullName && it.Name == @new.Name) .FirstOrDefault(); if (entity != null) { entity.Body = @new.Body; } else { entity = new HtmlBlockEntity(@new); dbContext.HtmlBlocks.Add(entity); } dbContext.SaveChanges(); }