// review public async Task <Cascade <int> > GetCascadeAsync(Site site, IChannelSummary summary, Func <IChannelSummary, Task <object> > func) { object extra = null; if (func != null) { extra = await func(summary); } if (extra == null) { return(null); } var cascade = new Cascade <int> { Value = summary.Id, Label = summary.ChannelName, Children = await GetCascadeChildrenAsync(site, summary.Id, func) }; var dict = TranslateUtils.ToDictionary(extra); foreach (var o in dict) { cascade[o.Key] = o.Value; } return(cascade); }
public async Task <Cascade <int> > GetCascadeAsync(Site site, IChannelSummary summary) { return(new Cascade <int> { Value = summary.Id, Label = summary.ChannelName, Children = await GetCascadeChildrenAsync(site, summary.Id) }); }
public async Task <int> GetFirstContentIdAsync(Site site, IChannelSummary channel) { var repository = GetRepository(site, channel); return(await repository.GetAsync <int>(Q .Select(nameof(Content.Id)) .Where(nameof(Content.ChannelId), channel.Id) .OrderByDesc(nameof(Content.Taxis), nameof(Content.Id)) )); }
public async Task <List <ContentSummary> > GetSummariesAsync(Site site, IChannelSummary channel) { var repository = GetRepository(site, channel); var query = Q.Select(nameof(Content.Id), nameof(Content.ChannelId), nameof(Content.Checked)); await QueryWhereAsync(query, site, channel.Id, false); query.OrderByDesc(nameof(Content.Taxis), nameof(Content.Id)); query.CachingGet(GetListKey(repository.TableName, site.Id, channel.Id)); return(await repository.GetAllAsync <ContentSummary>(query)); }
public string GetTableName(Site site, IChannelSummary channel) { return(channel != null?GetTableName(site, channel.TableName) : string.Empty); }
private async Task UpdateParentAsync(List <ChannelSummary> summaries, int sourceId, IChannelSummary parent) { var source = await GetAsync(sourceId); source.ParentId = parent.Id; source.ParentsPath = ListUtils.Add(parent.ParentsPath, parent.Id); source.ParentsCount = source.ParentsPath.Count; await UpdateAsync(source); var childIds = summaries .Where(x => x.ParentId == source.Id) .Select(x => x.Id) .ToList(); if (childIds.Count > 0) { foreach (var childId in childIds) { await UpdateParentAsync(summaries, childId, source); } } }
private async Task <Repository <Content> > GetRepositoryAsync(Site site, IChannelSummary channel) { var tableName = _channelRepository.GetTableName(site, channel); return(await GetRepositoryAsync(tableName)); }
private Repository <Content> GetRepository(Site site, IChannelSummary channel) { var tableName = _channelRepository.GetTableName(site, channel); return(GetRepository(tableName)); }
public async Task <int> GetCountAsync(Site site, IChannelSummary channel) { var summaries = await GetSummariesAsync(site, channel); return(summaries.Count); }