public PrismicService(ILogger <PrismicService> logger, IConfiguration configuration, IPrismicApiAccessor apiAccessor) { Logger = logger; ApiAccessor = apiAccessor; ApiUrl = configuration.GetSection("Prismic:Url").Value; shelfs = new Lazy <Task <List <Shelf> > >(async() => { var api = await GetApi(); var response = await api.Query(Predicates.At("document.type", "shelf")).PageSize(100).Submit(); return(response.Results.Select(x => x.ToShelf()).OrderBy(x => x.Order).ToList()); }); experiments = new Lazy <Task <List <Models.Experiment> > >(async() => { var api = await GetApi(); var response = await api.Query(Predicates.At("document.type", "experiment")).PageSize(100).Submit(); return(response.Results.Select(x => x.ToExperiment()).OrderBy(x => x.Order).ToList()); }); homepage = new Lazy <Task <Homepage> >(async() => { var api = await GetApi(); var response = await api.QueryFirst(Predicates.At("document.type", "homepage")); return(response.ToHomepage()); }); }
public async Task <IList <Project> > GetProjects() { if (_projects == null) { var api = await GetApi(); var response = await api.Query(Predicates.At("document.type", "project")).PageSize(100).Submit(); _projects = response.Results.Select(x => x.ToProject()).OrderBy(x => x.Order).ToList(); } return(_projects); }
protected async Task <Document> GetSingle(string documentType) { var api = await GetApi(); return(await api.QueryFirst(Predicates.At("document.type", documentType))); }