Example #1
0
 public async Task <Data.IData?> GetDataAsync(
     Guid id,
     DateTime?timestamp,
     [GraphQLType(typeof(LocaleType))] string?locale,
     CalorimetricDataByIdDataLoader calorimetricDataById,
     HygrothermalDataByIdDataLoader hygrothermalDataById,
     OpticalDataByIdDataLoader opticalDataById,
     PhotovoltaicDataByIdDataLoader photovoltaicDataById,
     CancellationToken cancellationToken
     )
 {
     // TODO Use `timestamp` and `locale`.
     return
         (await calorimetricDataById.LoadAsync(
              id,
              cancellationToken
              ).ConfigureAwait(false) ??
          await hygrothermalDataById.LoadAsync(
              id,
              cancellationToken
              ).ConfigureAwait(false) ??
          await opticalDataById.LoadAsync(
              id,
              cancellationToken
              ).ConfigureAwait(false) ??
          (await photovoltaicDataById.LoadAsync(
               id,
               cancellationToken
               ).ConfigureAwait(false) as Data.IData));
 }
        public async Task <Data.IData?> GetData(
            [Parent] Data.GetHttpsResource getHttpsResource,
            CalorimetricDataByIdDataLoader calorimetricDataById,
            HygrothermalDataByIdDataLoader hygrothermalDataById,
            OpticalDataByIdDataLoader opticalDataById,
            PhotovoltaicDataByIdDataLoader photovoltaicDataById,
            CancellationToken cancellationToken

            )
        {
            if (getHttpsResource.CalorimetricDataId is not null)
            {
                return(await calorimetricDataById.LoadAsync(
                           getHttpsResource.CalorimetricDataId ?? throw new Exception("Impossible!"),
                           cancellationToken
                           ).ConfigureAwait(false));
            }
            if (getHttpsResource.HygrothermalDataId is not null)
            {
                return(await hygrothermalDataById.LoadAsync(
                           getHttpsResource.HygrothermalDataId ?? throw new Exception("Impossible!"),
                           cancellationToken
                           ).ConfigureAwait(false));
            }
            if (getHttpsResource.OpticalDataId is not null)
            {
                return(await opticalDataById.LoadAsync(
                           getHttpsResource.OpticalDataId ?? throw new Exception("Impossible!"),
                           cancellationToken
                           ).ConfigureAwait(false));
            }
            if (getHttpsResource.PhotovoltaicDataId is not null)
            {
                return(await photovoltaicDataById.LoadAsync(
                           getHttpsResource.PhotovoltaicDataId ?? throw new Exception("Impossible!"),
                           cancellationToken
                           ).ConfigureAwait(false));
            }
            return(null);
        }