protected HygrothermalDataPayload( Data.HygrothermalData hygrothermalData, IReadOnlyCollection <THygrothermalDataError> errors ) { HygrothermalData = hygrothermalData; Errors = errors; }
public Task <Data.GetHttpsResource[]> GetGetHttpsResources( [Parent] Data.HygrothermalData hygrothermalData, GetHttpsResourcesByDataIdDataLoader byId, CancellationToken cancellationToken ) { return(byId.LoadAsync(hygrothermalData.Id, cancellationToken)); }
protected HygrothermalDataPayload( Data.HygrothermalData hygrothermalData, THygrothermalDataError error ) : this( hygrothermalData, new[] { error } ) { }
// [UseUserManager] // [Authorize(Policy = Configuration.AuthConfiguration.WritePolicy)] public async Task <CreateHygrothermalDataPayload> CreateHygrothermalDataAsync( CreateHygrothermalDataInput input, // [GlobalState(nameof(ClaimsPrincipal))] ClaimsPrincipal claimsPrincipal, // [ScopedService] UserManager<Data.User> userManager, [ScopedService] Data.ApplicationDbContext context, [Service] AppSettings appSettings, CancellationToken cancellationToken ) { // if (!await HygrothermalDataAuthorization.IsAuthorizedToCreateHygrothermalDataForInstitution( // claimsPrincipal, // input.CreatorId, // userManager, // context, // cancellationToken // ).ConfigureAwait(false) // ) if (input.AccessToken != appSettings.AccessToken) { return(new CreateHygrothermalDataPayload( new CreateHygrothermalDataError( CreateHygrothermalDataErrorCode.UNAUTHORIZED, $"The access token {input.AccessToken} is invalid.", new[] { nameof(input), nameof(input.AccessToken).FirstCharToLower() } ) )); } var hygrothermalData = new Data.HygrothermalData( locale: input.Locale, componentId: input.ComponentId, name: input.Name, description: input.Description, warnings: input.Warnings, creatorId: input.CreatorId, createdAt: input.CreatedAt, appliedMethod: new Data.AppliedMethod( methodId: input.AppliedMethod.MethodId, arguments: input.AppliedMethod.Arguments .Select(a => new Data.NamedMethodArgument( name: a.Name, // TODO Turn `a.Value` into `JsonDocument`. It comes // as nested `IReadOnlyDictionary/-List` as said on // https://chillicream.com/docs/hotchocolate/v11/defining-a-schema/scalars/#any-type // Take inspiration from // https://josef.codes/custom-dictionary-string-object-jsonconverter-for-system-text-json/ // and // https://github.com/joseftw/JOS.SystemTextJsonDictionaryStringObjectJsonConverter/blob/develop/src/JOS.SystemTextJsonDictionaryObjectModelBinder/DictionaryStringObjectJsonConverter.cs // This is also needed in `GetHttpsResourceMutations`. value: JsonDocument.Parse(@"""TODO""") )) .ToList(), sources: input.AppliedMethod.Sources .Select(s => new Data.NamedMethodSource( name: s.Name, value: new Data.CrossDatabaseDataReference( dataId: s.Value.DataId, dataTimestamp: s.Value.DataTimestamp, dataKind: s.Value.DataKind, databaseId: s.Value.DatabaseId ) )) .ToList() ), approvals: input.Approvals.Select(a => new Data.DataApproval( timestamp: a.Timestamp, signature: a.Signature, keyFingerprint: a.KeyFingerprint, query: a.Query, response: a.Response, approverId: a.ApproverId ) ).ToList() // approval: input.Approval ); var resource = new Data.GetHttpsResource( description: input.RootResource.Description, hashValue: input.RootResource.HashValue, dataFormatId: input.RootResource.DataFormatId, parentId: null, archivedFilesMetaInformation: input.RootResource.ArchivedFilesMetaInformation.Select(i => new Data.FileMetaInformation( path: i.Path, dataFormatId: i.DataFormatId ) ).ToList(), appliedConversionMethod: input.RootResource.AppliedConversionMethod is null ? null : new Data.ToTreeVertexAppliedConversionMethod( methodId: input.RootResource.AppliedConversionMethod.MethodId, arguments: input.RootResource.AppliedConversionMethod.Arguments.Select(a => new Data.NamedMethodArgument( name: a.Name, // TODO Turn `a.Value` into `JsonDocument`. It comes // as nested `IReadOnlyDictionary/-List` as said on // https://chillicream.com/docs/hotchocolate/v11/defining-a-schema/scalars/#any-type // Take inspiration from // https://josef.codes/custom-dictionary-string-object-jsonconverter-for-system-text-json/ // and // https://github.com/joseftw/JOS.SystemTextJsonDictionaryStringObjectJsonConverter/blob/develop/src/JOS.SystemTextJsonDictionaryObjectModelBinder/DictionaryStringObjectJsonConverter.cs // This is also needed in `GetHttpsResourceMutations`. value: JsonDocument.Parse(@"""TODO""") ) ).ToList(), sourceName: input.RootResource.AppliedConversionMethod.SourceName ) ); hygrothermalData.Resources.Add(resource); context.HygrothermalData.Add(hygrothermalData); await context.SaveChangesAsync(cancellationToken).ConfigureAwait(false); return(new CreateHygrothermalDataPayload(hygrothermalData)); }
public CreateHygrothermalDataPayload( Data.HygrothermalData hygrothermalData ) : base(hygrothermalData) { }
protected HygrothermalDataPayload( Data.HygrothermalData hygrothermalData ) { HygrothermalData = hygrothermalData; }
public GetHttpsResourceTree GetGetHttpsResourceTree( [Parent] Data.HygrothermalData hygrothermalData ) { return(new GetHttpsResourceTree(hygrothermalData)); }