Exemplo n.º 1
0
        public async Task <ApiResponse> GetStockRepot(GetStockRepotRequestModel options)
        {
            ApiResponse response = new ApiResponse();

            int _pageNo    = (options.pageNo == 0) ? 1 : options.pageNo;
            int _pageLimit = (options.pageSize == 0) ? int.MaxValue : options.pageSize;

            var stocks = from stock in _context.Stocks
                         join prod in _context.Products on stock.ProductId equals prod.ProductId
                         join cat in _context.Categories on prod.CategoryId equals cat.CategoryId
                         select new
            {
                ProductName       = prod.Name,
                CategoryName      = cat.Name,
                CategoryCode      = cat.CatCode,
                ProductCode       = prod.ProductCode,
                CategoryId        = cat.CategoryId,
                AvailableQuantity = stock.AvailableQuantity,
                LastUpdated       = stock.LastUpdated
            };

            if (options.CategoryId > 0)
            {
                stocks = stocks.Where(x => x.CategoryId == options.CategoryId);
            }

            response.Data = await stocks.Skip((_pageNo - 1) *_pageLimit).Take(_pageLimit).ToListAsync();

            response.Message = "Stock report get successfully";
            response.Status  = 1;

            return(response);
        }
        public async Task <IActionResult> GetStockRepot([FromQuery] GetStockRepotRequestModel options)
        {
            var cat = await tansactionService.GetStockRepot(options);

            if (cat.Status == 1)
            {
                return(Ok(cat));
            }
            else
            {
                return(NotFound(cat));
            }
        }