public static async Task <bool> ImportAsync(IChannelGroupRepository channelGroupRepository, AtomEntry entry, int siteId) { var isNodeGroup = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, "IsNodeGroup")); if (!isNodeGroup) { return(false); } var groupName = AtomUtility.GetDcElementContent(entry.AdditionalElements, new List <string> { nameof(ChannelGroup.GroupName), "NodeGroupName" }); if (string.IsNullOrEmpty(groupName)) { return(true); } if (await channelGroupRepository.IsExistsAsync(siteId, groupName)) { return(true); } var taxis = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(ChannelGroup.Taxis))); var description = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(ChannelGroup.Description)); await channelGroupRepository.InsertAsync(new ChannelGroup { GroupName = groupName, SiteId = siteId, Taxis = taxis, Description = description }); return(true); }
public async Task <ActionResult <ListResult> > Add([FromBody] AddRequest request) { if (await _channelGroupRepository.IsExistsAsync(request.SiteId, request.GroupName)) { return(this.Error("保存失败,已存在相同名称的栏目组!")); } var groupInfo = new ChannelGroup { SiteId = request.SiteId, GroupName = request.GroupName, Description = request.Description }; await _channelGroupRepository.InsertAsync(groupInfo); await _authManager.AddSiteLogAsync(request.SiteId, "新增栏目组", $"栏目组:{groupInfo.GroupName}"); var groups = await _channelGroupRepository.GetChannelGroupsAsync(request.SiteId); var groupNames = groups.Select(x => x.GroupName); return(new ListResult { GroupNames = groupNames, Groups = groups }); }