Exemplo n.º 1
0
        public async Task <ActionResult <SingleStockReceiveDto> > Get(string id)
        {
            var spec   = new StockReceiveSpecification(id);
            var result = await _repository.GetEntityWithSpec(spec);

            if (result == null)
            {
                return(NotFound(new ApiResponse(404)));
            }
            return(_mapper.Map <StockReceive, SingleStockReceiveDto>(result));
        }
Exemplo n.º 2
0
        public async Task <ActionResult <Pagination <StockReceiveDto> > > Get([FromQuery] SpecParams specParams)
        {
            var spec       = new StockReceiveSpecification(specParams);
            var countSpec  = new StockReceiveCountSpecificication(specParams);
            var totalItems = await _repository.CountAsync(countSpec);

            var results = await _repository.ListAsync(spec);

            var data = _mapper.Map <IReadOnlyList <StockReceive>, IReadOnlyList <StockReceiveDto> >(results);

            return(Ok(new Pagination <StockReceiveDto>(specParams.PageIndex, specParams.PageSize, totalItems, data)));
        }