public SectionItemType(ISectionItemRepository sectionItemRepository) { Field(x => x.Tenant, nullable: true); Field(x => x.Id, nullable: true); Field(x => x.Name, nullable: true); Field(x => x.CreatedBy, nullable: true); Field(x => x.CreatedDate, nullable: true); Field(x => x.LastUpdate, nullable: true); Field(x => x.ParentId, nullable: true); Field(x => x.Section, nullable: true); Field(x => x.PathUrl, nullable: true); Field(x => x.PathName, nullable: true); Field(x => x.Alias, nullable: true); Field(x => x.Description, nullable: true); //Field<StringGraphType>("modules", resolve: context => context.Source.Modules); }
public BanicoMutation( IConfiguration configuration, ISectionRepository sectionRepository, ISectionItemRepository sectionItemRepository, IContentItemRepository contentItemRepository, IConfigRepository configRepository, IAccessService accessService ) { _configuration = configuration; _contentItemRepository = contentItemRepository; _configRepository = configRepository; _accessService = accessService; Name = "Mutation"; Field <SectionType>( "addOrUpdateSection", arguments: new QueryArguments( // <SectionInputType> new QueryArgument <NonNullGraphType <SectionInputType> > { Name = "section" } ), resolve: context => { var section = context.GetArgument <Section>("section"); this.StampItem(section).Wait(); var isSectionAdmin = _accessService.Allowed("admin/sections", "", false).Result; this.WriteDebugMessage("BanicoMutation: isSectionAdmin " + isSectionAdmin.ToString()); return(sectionRepository.AddOrUpdate(section, isSectionAdmin)); }); Field <SectionItemType>( "addOrUpdateSectionItem", arguments: new QueryArguments( // <SectionInputType> new QueryArgument <NonNullGraphType <SectionItemInputType> > { Name = "sectionItem" } ), resolve: context => { var sectionItem = context.GetArgument <SectionItem>("sectionItem"); this.StampItem(sectionItem).Wait(); var isSectionItemAdmin = _accessService.Allowed("admin/sectionItems", "", false).Result; return(sectionItemRepository.AddOrUpdate(sectionItem, isSectionItemAdmin)); }); Field <ContentItemType>( "addOrUpdateContentItem", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <ContentItemInputType> > { Name = "contentItem" } ), resolve: context => { var contentItem = context.GetArgument <ContentItem>("contentItem"); if (_accessService.IsEnabled(contentItem.Module).Result) { if (_accessService.Allowed(contentItem).Result) { if (!this.checkTenant(contentItem)) { throw new UnauthorizedAccessException("Update of content item is not allowed."); } this.StampItem(contentItem).Wait(); var userId = _accessService.GetUserId(); var isAdmin = _accessService.IsAdminOrSuperAdmin(); return(contentItemRepository.AddOrUpdate(contentItem, userId, isAdmin)); } else { var userId = _accessService.GetUserId(); throw new UnauthorizedAccessException("Add or update of content module / type " + contentItem.Module + " / " + contentItem.Type + " is not allowed for user " + userId + "."); } } else { throw new UnauthorizedAccessException("Content module " + contentItem.Module + " is not enabled."); } }); Field <ContentItemType>( "deleteContentItem", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "id" } ), resolve: context => { var id = context.GetArgument <String>("id"); if (!this.checkTenant(id)) { throw new UnauthorizedAccessException("Deletion of content item is not allowed."); } var userId = _accessService.GetUserId(); var isAdmin = _accessService.IsAdminOrSuperAdmin(); return(contentItemRepository.Delete(id, userId, isAdmin)); }); Field <ConfigType>( "addOrUpdateConfig", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <ConfigInputType> > { Name = "config" } ), resolve: context => { var config = context.GetArgument <Config>("config"); this.StampItem(config).Wait(); var isSuperAdmin = _accessService.IsSuperAdmin(); return(configRepository.AddOrUpdate(config, isSuperAdmin)); }); }
public GraphQLIssueMutation( ISectionRepository sectionRepository, ISectionItemRepository sectionItemRepository, IContentItemRepository contentItemRepository, IConfigRepository configRepository, IAccessService accessService ) { _configRepository = configRepository; _accessService = accessService; Field <SectionType>( "addOrUpdateSection", arguments: new QueryArguments( // <SectionInputType> new QueryArgument <NonNullGraphType <SectionInputType> > { Name = "section" } ), resolve: context => { var section = context.GetArgument <Section>("section"); this.StampItem(section); return(sectionRepository.AddOrUpdate(section)); }); Field <SectionItemType>( "addOrUpdateSectionItem", arguments: new QueryArguments( // <SectionInputType> new QueryArgument <NonNullGraphType <SectionItemInputType> > { Name = "sectionItem" } ), resolve: context => { var sectionItem = context.GetArgument <SectionItem>("sectionItem"); this.StampItem(sectionItem); return(sectionItemRepository.AddOrUpdate(sectionItem)); }); Field <ContentItemType>( "addOrUpdateContentItem", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <ContentItemInputType> > { Name = "contentItem" }, new QueryArgument <StringGraphType> { Name = "sectionItems" } ), resolve: context => { var contentItem = context.GetArgument <ContentItem>("contentItem"); var sectionItems = context.GetArgument <String>("sectionItems"); if (_accessService.Allowed(contentItem).Result) { this.StampItem(contentItem); var userId = _accessService.GetCurrentUserId(); var isAdmin = _accessService.IsAdmin(); return(contentItemRepository.AddOrUpdate(contentItem, sectionItems, userId, isAdmin)); } else { return(new ContentItem()); } }); Field <ConfigType>( "addOrUpdateConfig", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <ConfigInputType> > { Name = "config" } ), resolve: context => { var config = context.GetArgument <Config>("config"); this.StampItem(config); return(configRepository.AddOrUpdate(config)); }); }
public BanicoMutation( ISectionRepository sectionRepository, ISectionItemRepository sectionItemRepository, IContentItemRepository contentItemRepository ) { Name = "BanicoMutation"; Field <SectionType>( "addSection", arguments: new QueryArguments( // <SectionInputType> new QueryArgument <NonNullGraphType <SectionInputType> > { Name = "section" } ), resolve: context => { var section = context.GetArgument <Section>("section"); return(sectionRepository.Add(section)); }); Field <SectionItemType>( "addSectionItem", arguments: new QueryArguments( // <SectionInputType> new QueryArgument <NonNullGraphType <SectionItemInputType> > { Name = "sectionItem" } ), resolve: context => { var sectionItem = context.GetArgument <SectionItem>("sectionItem"); return(sectionItemRepository.Add(sectionItem)); }); Field <ContentItemType>( "addContentItem", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <ContentItemInputType> > { Name = "contentItem" } ), resolve: context => { var contentItem = context.GetArgument <ContentItem>("contentItem"); return(contentItemRepository.Add(contentItem)); }); Field <ContentItemType>( "updateContentItem", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <ContentItemInputType> > { Name = "contentItem" } ), resolve: context => { var contentItem = context.GetArgument <ContentItem>("contentItem"); return(contentItemRepository.Update(contentItem)); }); }
public BanicoQuery( ISectionRepository sectionRepository, ISectionItemRepository sectionItemRepository, IContentItemRepository contentItemRepository) { Field <ListGraphType <SectionType> >( "sections", arguments: new QueryArguments( new QueryArgument <StringGraphType> { Name = "id" }, new QueryArgument <StringGraphType> { Name = "module" }, new QueryArgument <StringGraphType> { Name = "name" } ), resolve: context => sectionRepository.Get( context.GetArgument <string>("id"), context.GetArgument <string>("module"), context.GetArgument <string>("name") )); Field <ListGraphType <SectionItemType> >( "sectionItems", arguments: new QueryArguments( new QueryArgument <StringGraphType> { Name = "id" }, new QueryArgument <StringGraphType> { Name = "section" }, new QueryArgument <StringGraphType> { Name = "pathUrl" }, new QueryArgument <StringGraphType> { Name = "alias" }, new QueryArgument <StringGraphType> { Name = "name" }, new QueryArgument <StringGraphType> { Name = "parentId" }, new QueryArgument <BooleanGraphType> { Name = "isRoot" } ), resolve: context => sectionItemRepository.Get( context.GetArgument <string>("id"), context.GetArgument <string>("section"), context.GetArgument <string>("pathUrl"), context.GetArgument <string>("alias"), context.GetArgument <string>("name"), context.GetArgument <string>("parentId"), context.GetArgument <bool>("isRoot") ) ); Field <ListGraphType <ContentItemType> >( "contentItems", arguments: new QueryArguments( new QueryArgument <StringGraphType> { Name = "id" }, new QueryArgument <StringGraphType> { Name = "name" }, new QueryArgument <StringGraphType> { Name = "alias" }, new QueryArgument <StringGraphType> { Name = "module" }, new QueryArgument <StringGraphType> { Name = "parentId" }, new QueryArgument <StringGraphType> { Name = "createdBy" }, new QueryArgument <StringGraphType> { Name = "sectionItems" }, new QueryArgument <StringGraphType> { Name = "content" }, new QueryArgument <StringGraphType> { Name = "attribute01" }, new QueryArgument <StringGraphType> { Name = "attribute02" }, new QueryArgument <StringGraphType> { Name = "attribute03" }, new QueryArgument <StringGraphType> { Name = "attribute04" }, new QueryArgument <StringGraphType> { Name = "attribute05" }, new QueryArgument <StringGraphType> { Name = "attribute06" }, new QueryArgument <StringGraphType> { Name = "attribute07" }, new QueryArgument <StringGraphType> { Name = "attribute08" }, new QueryArgument <StringGraphType> { Name = "attribute09" }, new QueryArgument <StringGraphType> { Name = "attribute10" }, new QueryArgument <StringGraphType> { Name = "attribute11" }, new QueryArgument <StringGraphType> { Name = "attribute12" }, new QueryArgument <StringGraphType> { Name = "attribute13" }, new QueryArgument <StringGraphType> { Name = "attribute14" }, new QueryArgument <StringGraphType> { Name = "attribute15" }, new QueryArgument <StringGraphType> { Name = "attribute16" }, new QueryArgument <StringGraphType> { Name = "attribute17" }, new QueryArgument <StringGraphType> { Name = "attribute18" }, new QueryArgument <StringGraphType> { Name = "attribute19" }, new QueryArgument <StringGraphType> { Name = "attribute20" } ), resolve: context => contentItemRepository.Get( context.GetArgument <string>("id"), context.GetArgument <string>("name"), context.GetArgument <string>("alias"), context.GetArgument <string>("module"), context.GetArgument <string>("parentId"), context.GetArgument <string>("createdBy"), context.GetArgument <string>("sectionItems"), context.GetArgument <string>("content"), context.GetArgument <string>("attribute01"), context.GetArgument <string>("attribute02"), context.GetArgument <string>("attribute03"), context.GetArgument <string>("attribute04"), context.GetArgument <string>("attribute05"), context.GetArgument <string>("attribute06"), context.GetArgument <string>("attribute07"), context.GetArgument <string>("attribute08"), context.GetArgument <string>("attribute09"), context.GetArgument <string>("attribute10"), context.GetArgument <string>("attribute11"), context.GetArgument <string>("attribute12"), context.GetArgument <string>("attribute13"), context.GetArgument <string>("attribute14"), context.GetArgument <string>("attribute15"), context.GetArgument <string>("attribute16"), context.GetArgument <string>("attribute17"), context.GetArgument <string>("attribute18"), context.GetArgument <string>("attribute19"), context.GetArgument <string>("attribute20") ) ); }
//private IConfiguration _configuration; public BanicoQuery( IAccessService accessService, ISectionRepository sectionRepository, ISectionItemRepository sectionItemRepository, IContentItemRepository contentItemRepository, IConfigRepository configRepository, IOEmbedService oEmbedService) { Name = "Query"; Field <ListGraphType <SectionType> >( "sections", arguments: new QueryArguments( new QueryArgument <StringGraphType> { Name = "id" }, new QueryArgument <StringGraphType> { Name = "module" }, new QueryArgument <StringGraphType> { Name = "name" } ), resolve: context => { string tenant = string.Empty; return(sectionRepository.Get( tenant, context.GetArgument <string>("id"), context.GetArgument <string>("module"), context.GetArgument <string>("name") )); }); Field <ListGraphType <SectionItemType> >( "sectionItems", arguments: new QueryArguments( new QueryArgument <StringGraphType> { Name = "id" }, new QueryArgument <StringGraphType> { Name = "section" }, new QueryArgument <StringGraphType> { Name = "pathUrl" }, new QueryArgument <StringGraphType> { Name = "alias" }, new QueryArgument <StringGraphType> { Name = "name" }, new QueryArgument <StringGraphType> { Name = "parentId" }, new QueryArgument <BooleanGraphType> { Name = "isRoot" } ), resolve: (context) => { string tenant = string.Empty; return(sectionItemRepository.Get( tenant, context.GetArgument <string>("id"), context.GetArgument <string>("section"), context.GetArgument <string>("pathUrl"), context.GetArgument <string>("alias"), context.GetArgument <string>("name"), context.GetArgument <string>("parentId"), context.GetArgument <bool>("isRoot") )); } ); Field <MaxPageSizeType>( "maxPageSize", resolve: context => contentItemRepository.GetMaxPageSize() ); Field <ContentItemsCountType>( "contentItemsCount", arguments: new QueryArguments( new QueryArgument <StringGraphType> { Name = "id" }, new QueryArgument <StringGraphType> { Name = "name" }, new QueryArgument <StringGraphType> { Name = "alias" }, new QueryArgument <StringGraphType> { Name = "module" }, new QueryArgument <StringGraphType> { Name = "type" }, new QueryArgument <StringGraphType> { Name = "parentId" }, new QueryArgument <StringGraphType> { Name = "createdBy" }, new QueryArgument <StringGraphType> { Name = "sectionItems" }, new QueryArgument <StringGraphType> { Name = "content" }, new QueryArgument <StringGraphType> { Name = "attribute01" }, new QueryArgument <StringGraphType> { Name = "attribute02" }, new QueryArgument <StringGraphType> { Name = "attribute03" }, new QueryArgument <StringGraphType> { Name = "attribute04" }, new QueryArgument <StringGraphType> { Name = "attribute05" }, new QueryArgument <StringGraphType> { Name = "attribute06" }, new QueryArgument <StringGraphType> { Name = "attribute07" }, new QueryArgument <StringGraphType> { Name = "attribute08" }, new QueryArgument <StringGraphType> { Name = "attribute09" }, new QueryArgument <StringGraphType> { Name = "attribute10" }, new QueryArgument <StringGraphType> { Name = "attribute11" }, new QueryArgument <StringGraphType> { Name = "attribute12" }, new QueryArgument <StringGraphType> { Name = "attribute13" }, new QueryArgument <StringGraphType> { Name = "attribute14" }, new QueryArgument <StringGraphType> { Name = "attribute15" }, new QueryArgument <StringGraphType> { Name = "attribute16" }, new QueryArgument <StringGraphType> { Name = "attribute17" }, new QueryArgument <StringGraphType> { Name = "attribute18" }, new QueryArgument <StringGraphType> { Name = "attribute19" }, new QueryArgument <StringGraphType> { Name = "attribute20" }, new QueryArgument <BooleanGraphType> { Name = "includeChildren" }, new QueryArgument <BooleanGraphType> { Name = "includeParents" }), resolve: context => { string tenant = accessService.DomainTenant(); return(contentItemRepository.GetCount( tenant, context.GetArgument <string>("id"), context.GetArgument <string>("name"), context.GetArgument <string>("alias"), context.GetArgument <string>("module"), context.GetArgument <string>("type"), context.GetArgument <string>("parentId"), context.GetArgument <string>("createdBy"), context.GetArgument <string>("sectionItems"), context.GetArgument <string>("content"), context.GetArgument <string>("attribute01"), context.GetArgument <string>("attribute02"), context.GetArgument <string>("attribute03"), context.GetArgument <string>("attribute04"), context.GetArgument <string>("attribute05"), context.GetArgument <string>("attribute06"), context.GetArgument <string>("attribute07"), context.GetArgument <string>("attribute08"), context.GetArgument <string>("attribute09"), context.GetArgument <string>("attribute10"), context.GetArgument <string>("attribute11"), context.GetArgument <string>("attribute12"), context.GetArgument <string>("attribute13"), context.GetArgument <string>("attribute14"), context.GetArgument <string>("attribute15"), context.GetArgument <string>("attribute16"), context.GetArgument <string>("attribute17"), context.GetArgument <string>("attribute18"), context.GetArgument <string>("attribute19"), context.GetArgument <string>("attribute20"), context.GetArgument <bool>("includeChildren"), context.GetArgument <bool>("includeParents") )); }); Field <ListGraphType <ContentItemType> >( "contentItems", arguments: new QueryArguments( new QueryArgument <StringGraphType> { Name = "id" }, new QueryArgument <StringGraphType> { Name = "name" }, new QueryArgument <StringGraphType> { Name = "alias" }, new QueryArgument <StringGraphType> { Name = "module" }, new QueryArgument <StringGraphType> { Name = "type" }, new QueryArgument <StringGraphType> { Name = "parentId" }, new QueryArgument <StringGraphType> { Name = "createdBy" }, new QueryArgument <StringGraphType> { Name = "sectionItems" }, new QueryArgument <StringGraphType> { Name = "content" }, new QueryArgument <StringGraphType> { Name = "attribute01" }, new QueryArgument <StringGraphType> { Name = "attribute02" }, new QueryArgument <StringGraphType> { Name = "attribute03" }, new QueryArgument <StringGraphType> { Name = "attribute04" }, new QueryArgument <StringGraphType> { Name = "attribute05" }, new QueryArgument <StringGraphType> { Name = "attribute06" }, new QueryArgument <StringGraphType> { Name = "attribute07" }, new QueryArgument <StringGraphType> { Name = "attribute08" }, new QueryArgument <StringGraphType> { Name = "attribute09" }, new QueryArgument <StringGraphType> { Name = "attribute10" }, new QueryArgument <StringGraphType> { Name = "attribute11" }, new QueryArgument <StringGraphType> { Name = "attribute12" }, new QueryArgument <StringGraphType> { Name = "attribute13" }, new QueryArgument <StringGraphType> { Name = "attribute14" }, new QueryArgument <StringGraphType> { Name = "attribute15" }, new QueryArgument <StringGraphType> { Name = "attribute16" }, new QueryArgument <StringGraphType> { Name = "attribute17" }, new QueryArgument <StringGraphType> { Name = "attribute18" }, new QueryArgument <StringGraphType> { Name = "attribute19" }, new QueryArgument <StringGraphType> { Name = "attribute20" }, new QueryArgument <BooleanGraphType> { Name = "includeChildren" }, new QueryArgument <BooleanGraphType> { Name = "includeParents" }, new QueryArgument <StringGraphType> { Name = "orderBy" }, new QueryArgument <StringGraphType> { Name = "thenBy" }, new QueryArgument <IntGraphType> { Name = "page" }, new QueryArgument <IntGraphType> { Name = "pageSize" }, new QueryArgument <IntGraphType> { Name = "offset" } ), resolve: context => { string tenant = accessService.DomainTenant(); return(contentItemRepository.Get( tenant, context.GetArgument <string>("id"), context.GetArgument <string>("name"), context.GetArgument <string>("alias"), context.GetArgument <string>("module"), context.GetArgument <string>("type"), context.GetArgument <string>("parentId"), context.GetArgument <string>("createdBy"), context.GetArgument <string>("sectionItems"), context.GetArgument <string>("content"), context.GetArgument <string>("attribute01"), context.GetArgument <string>("attribute02"), context.GetArgument <string>("attribute03"), context.GetArgument <string>("attribute04"), context.GetArgument <string>("attribute05"), context.GetArgument <string>("attribute06"), context.GetArgument <string>("attribute07"), context.GetArgument <string>("attribute08"), context.GetArgument <string>("attribute09"), context.GetArgument <string>("attribute10"), context.GetArgument <string>("attribute11"), context.GetArgument <string>("attribute12"), context.GetArgument <string>("attribute13"), context.GetArgument <string>("attribute14"), context.GetArgument <string>("attribute15"), context.GetArgument <string>("attribute16"), context.GetArgument <string>("attribute17"), context.GetArgument <string>("attribute18"), context.GetArgument <string>("attribute19"), context.GetArgument <string>("attribute20"), context.GetArgument <bool>("includeChildren"), context.GetArgument <bool>("includeParents"), context.GetArgument <string>("orderBy"), context.GetArgument <string>("thenBy"), context.GetArgument <int>("page"), context.GetArgument <int>("pageSize"), context.GetArgument <int>("offset") )); }); Field <ListGraphType <ConfigType> >( "configs", arguments: new QueryArguments( new QueryArgument <StringGraphType> { Name = "id" }, new QueryArgument <StringGraphType> { Name = "module" }, new QueryArgument <StringGraphType> { Name = "name" } ), resolve: context => configRepository.Get( context.GetArgument <string>("id"), context.GetArgument <string>("module"), context.GetArgument <string>("name") )); Field <OEmbedType>( "oEmbed", arguments: new QueryArguments( new QueryArgument <StringGraphType> { Name = "service" }, new QueryArgument <StringGraphType> { Name = "url" } ), resolve: context => { return(oEmbedService.GetOEmbed( context.GetArgument <string>("service"), context.GetArgument <string>("url") )); }); }