Beispiel #1
0
        public async Task <FinancialYear> FinancialYear(
            [Inject] DataLoaderContext dataLoaderContext,
            [Inject] OutputTypesMapperResolver mapperResolver,
            [Inject] IFinancialYearRepository repository)
        {
            Entities.FinancialYear financialYear = await dataLoaderContext
                                                   .GetOrAddBatchLoader <Guid, Entities.FinancialYear>(nameof(repository.GetFinancialYearsInBatch), repository.GetFinancialYearsInBatch)
                                                   .LoadAsync(FinancialYearId);

            return(mapperResolver().Map <FinancialYear>(financialYear));
        }
Beispiel #2
0
        public async Task <Supplier> Supplier(
            [Inject] DataLoaderContext dataLoaderContext,
            [Inject] OutputTypesMapperResolver mapperResolver,
            [Inject] ISupplierRepository repository)
        {
            if (!SupplierId.HasValue)
            {
                return(null);
            }

            Entities.Supplier supplier = await dataLoaderContext
                                         .GetOrAddBatchLoader <Guid, Entities.Supplier>(nameof(repository.GetSuppliersInBatch), repository.GetSuppliersInBatch)
                                         .LoadAsync(SupplierId.Value);

            return(mapperResolver().Map <Supplier>(supplier));
        }
 public static IDataLoader <TKey, T> GetOrAddBatchLoader <TKey, T>(this DataLoaderContext context, Func <IEnumerable <TKey>, Task <IDictionary <TKey, T> > > fetchFunc, IEqualityComparer <TKey> keyComparer = null, T defaultValue = default)
 {
     return(context.GetOrAddBatchLoader(nameof(fetchFunc.Method.Name), fetchFunc, keyComparer, defaultValue));
 }
Beispiel #4
0
        public async Task <Country> Country([Inject] ICountryRepository repository, [Inject] DataLoaderContext dataLoaderContext)
        {
            var loader = dataLoaderContext.GetOrAddBatchLoader <string, Models.Country>("Actor_Country", repository.GetCountries);

            return(Mapper.Map <Country>(await loader.LoadAsync(CountryCode)));
        }