public async Task UpdateAsync(Site site, Channel channel, Content content) { if (content == null) { return; } var repository = GetRepository(site, channel); if (site.IsAutoPageInTextEditor) { content.Body = ContentUtility.GetAutoPageBody(content.Body, site.AutoPageWordNum); } if (content.Top == false && content.Taxis >= TaxisIsTopStartValue) { content.Taxis = await GetMaxTaxisAsync(site, channel, false) + 1; } else if (content.Top && content.Taxis < TaxisIsTopStartValue) { content.Taxis = await GetMaxTaxisAsync(site, channel, true) + 1; } await repository.UpdateAsync(content, Q .CachingRemove(GetListKey(repository.TableName, content.SiteId, content.ChannelId)) .CachingRemove(GetEntityKey(repository.TableName, content.Id)) ); await _statRepository.AddCountAsync(StatType.ContentEdit, content.SiteId); }
public async Task SetAutoPageContentToSiteAsync(Site site) { if (!site.IsAutoPageInTextEditor) { return; } var tableNames = await _siteRepository.GetAllTableNamesAsync(); foreach (var tableName in tableNames) { var repository = GetRepository(tableName); var list = await repository.GetAllAsync <(int ContentId, string Content)>( GetQuery(site.Id) .Select(nameof(Content.Id), nameof(Content.Body)) ); foreach (var(contentId, contentValue) in list) { var body = ContentUtility.GetAutoPageBody(contentValue, site.AutoPageWordNum); await repository.UpdateAsync( GetQuery(site.Id) .Set(nameof(Content.Body), body) .Where(nameof(Content.Id), contentId) .CachingRemove(GetEntityKey(tableName, contentId)) ); } } }
public async Task <int> InsertWithTaxisAsync(Site site, Channel channel, Content content, int taxis) { if (site.IsAutoPageInTextEditor) { content.Body = ContentUtility.GetAutoPageBody(content.Body, site.AutoPageWordNum); } content.Taxis = taxis; var tableName = _channelRepository.GetTableName(site, channel); if (string.IsNullOrEmpty(tableName)) { return(0); } var repository = await GetRepositoryAsync(tableName); if (content.SourceId == SourceManager.Preview) { await repository.InsertAsync(content); } else { await repository.InsertAsync(content, Q.CachingRemove(GetListKey(tableName, content.SiteId, content.ChannelId))); await _statRepository.AddCountAsync(StatType.ContentAdd, content.SiteId); } return(content.Id); }