示例#1
0
        public async Task <Tuple <int, List <WarehouseProductCheckFullDTO> > > LoadAsyncCount(
            int warehouseId,
            int skip = -1,
            int take = -1,
            WarehouseProductCheckSearchViewModel model = null)
        {
            var query = Entities.Include(x => x.Product).ProjectTo <WarehouseProductCheckFullDTO>().Where(x => x.WarehouseId == warehouseId);

            if (!string.IsNullOrEmpty(model.ProductTitle))
            {
                query = query.Where(x => x.Product.Title.Contains(model.ProductTitle));
            }

            if (model.Count != null)
            {
                query = query.Where(x => x.Count == model.Count);
            }

            if (model.Type != null)
            {
                query = query.Where(x => x.TypeSSOt == model.Type);
            }


            //if (model.Id != null)
            //    query = query.Where(x => x.Id == model.Id);

            //if (!string.IsNullOrEmpty(model.Title))
            //    query = query.Where(x => x.Title.Contains(model.Title));

            //if (model.ParentId != null)
            //    query = query.Where(x => x.ParentId == model.ParentId);

            int Count = query.Count();

            query = query.OrderByDescending(x => x.Id);


            if (skip != -1)
            {
                query = query.Skip((skip - 1) * take);
            }

            if (take != -1)
            {
                query = query.Take(take);
            }

            return(new Tuple <int, List <WarehouseProductCheckFullDTO> >(Count, await query.ToListAsync()));
        }
        public async Task <IActionResult> Index(int id, WarehouseProductCheckSearchViewModel searchModel)
        {
            var model = await _warehouseProductCheckRepository.LoadAsyncCount(
                id,
                this.CurrentPage,
                this.PageSize,
                searchModel);

            this.TotalNumber = model.Item1;

            ViewBag.SearchModel = searchModel;
            ViewBag.WarehouseId = id;
            return(View(model.Item2));

            //var model = await _warehouseProductCheckRepository.GetAllTransactionInWarehouse(id);

            //ViewBag.WarehouseId = id;

            //return View(model);
        }