public async Task <IActionResult> Stores() { try { var stores = await _bikeStoreRepository.GetStores(); return(Ok(stores)); } catch (Exception ex) { this._logger.LogError(ex, ex.Message); return(new StatusCodeResult(Status500InternalServerError)); } }
public SalesQuery(IBikeStoreRepository bikeStoreRepository) { Field <ListGraphType <StaffType> >( "staff", resolve: context => { return(bikeStoreRepository.GetStaff()); }); Field <ListGraphType <StoreType> >( "stores", resolve: context => { return(bikeStoreRepository.GetStores()); }); }
public StaffType(IDataLoaderContextAccessor accessor, IBikeStoreRepository bikeStoreRepository) { Field(t => t.Active); Field(t => t.Email); Field(t => t.FirstName); Field(t => t.LastName); Field(t => t.ManagerId, nullable: true); Field(t => t.Phone); Field(t => t.StaffId); Field <StoreType, Store>() .Name("store") .ResolveAsync(context => { var loader = accessor.Context.GetOrAddBatchLoader <int, Store>( "StoreTypeLoader", async storeIds => { var stores = await bikeStoreRepository.GetStores(); return(stores.ToDictionary(s => s.Id, s => s)); }); return(loader.LoadAsync(context.Source.StoreId)); }); }