public IActionResult GetWorkorders([FromQuery] WorkorderFilterParams filterParams) { IEnumerable <Workorder> workorders; if (filterParams.Limit != null) { workorders = _context.Workorders .Include(w => w.State) .Include(w => w.Faculty) .Include(w => w.Purpose) .OrderByDescending(w => w.Id) .Take((int)filterParams.Limit).ToList(); } else { workorders = _context.Workorders .Include(w => w.State) .Include(w => w.Faculty) .Include(w => w.Purpose); } var hal = new HalRepresentation() .AddEmbeddedResource("workorders", workorders, this.Request.Path) .AddLink("self", this.Request.Path, HttpType.GET); return(Ok(workorders)); //return Ok(hal.GetRepresentation()); }
private static Task <string> Render(Type type, HalRepresentation representation) => Engines .GetOrAdd(type.Assembly, assembly => new RazorLightEngineBuilder() .UseEmbeddedResourcesProject(assembly) .UseMemoryCachingProvider() .Build()) .CompileRenderAsync(type.FullName, representation.State);