コード例 #1
0
ファイル: HtmlBlockProvider.cs プロジェクト: Epitomy/CMS
        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();
        }
コード例 #2
0
ファイル: HtmlBlockProvider.cs プロジェクト: Epitomy/CMS
        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();
        }
コード例 #3
0
 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();
 }
コード例 #4
0
        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();
        }