示例#1
0
        public async Task <ActionResult <IEnumerable <MarcaDTO> > > Get([FromQuery] MarcaQueryFilter filters)
        {
            var location = new ResourceLocation()
            {
                Scheme = Request.Scheme, Host = Request.Host.Value, PathBase = Request.PathBase
            };
            var marcas = await _marcaService.GetMarcas(filters, location);

            var marcasDTO = _mapper.Map <IEnumerable <MarcaDTO> >(marcas);
            var metadata  = new MetaData().BuildMeta <Marca>(marcas, filters, Request.Path.Value, _uriService);
            var response  = new ApiResponse <IEnumerable <MarcaDTO> >(marcasDTO)
            {
                Meta = metadata
            };

            Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(metadata));
            return(Ok(response));
        }