示例#1
0
        async Task <PreflightResources> GetPreflightResourcesAsync(IEnumerable <IPanelDTO> panels)
        {
            var requested = panels.SelectMany(p => p.SubPanels)
                            .SelectMany(s => s.PanelItems)
                            .Select(i => i.Resource);
            var resources = new ResourceRefs(requested);

            return(await preflightReader.GetAsync(resources));
        }
示例#2
0
        public async Task <ActionResult <PreflightCheckDTO> > Preflight(
            [FromBody] ResourceRef resourceRef,
            [FromServices] IPreflightResourceReader preflightReader)
        {
            try
            {
                var refs = new ResourceRefs(new ResourceRef[] { resourceRef });
                var preflightResources = await preflightReader.GetAsync(refs);

                return(Ok(new PreflightCheckDTO(preflightResources)));
            }
            catch (LeafDbException lde)
            {
                return(StatusCode(lde.StatusCode));
            }
            catch (Exception e)
            {
                log.LogError("Could not preflight resource. Resource:{@Resource} Error:{Error}", resourceRef, e.ToString());
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }