Example #1
0
        public async Task <int> GetProductStock(int ProductId, int SizeId, int ColorId)
        {
            // 3.系統在Post Action【Mall/GetProductStock】讀取商品庫存。
            ProductStockListViewModel model = await IPRR.GetProductStock(ProductId, SizeId, ColorId);

            if (model != null)
            {
                // 4.系統判斷3傳回值!=null。
                // 5.系統傳回3傳回值之Stock。
                return(model.Stock);
            }
            // 4a.系統判斷3傳回值==null。
            //  4a-1.系統傳回0。
            return(0);
        }
Example #2
0
        public async Task <IActionResult> ProductDetailBlank(int ProductId, int MemberLevelId = -1)
        {
            // 2-1.系統在Get Controller Action【Mall/GetProductDetail】呼叫ViewComponent【ProductDetail】並傳送2傳送之商品代碼。
            // 3.系統在ViewComponent【ProductDetail】讀取商品基本資料。
            ProductListViewModel PLVM = await IPRR.GetProduct(ProductId);

            // 4.系統在ViewComponent【ProductDetail】讀取商品尺寸資料。
            List <ProductSizeViewModel> lstPSVM = IPRR.GetProductSizeSync(ProductId);
            // 5.系統在ViewComponent【ProductDetail】讀取商品顏色資料。
            List <ProductColorViewModel> lstPCVM = IPRR.GetProductColorSync(ProductId);

            ProductStockListViewModel PSLVM;

            if (lstPSVM == null || lstPCVM == null || lstPSVM.Count == 0 || lstPCVM.Count == 0)
            {
                PSLVM = null;
            }
            else
            {
                // 6.系統在ViewComponent【ProductDetail】讀取商品第1個尺寸第1個顏色的庫存資料。
                PSLVM = await IPRR.GetProductStock(ProductId, lstPSVM[0].ProducSizeId, lstPCVM[0].ProductColorId);

                if (PSLVM == null)
                {
                    // 6-1a.系統判斷6傳回null。
                    //  6-1a-1.系統New ProductStockListViewModel {},將Stock設為0。
                    PSLVM = new ProductStockListViewModel {
                        ProductId = ProductId, ProducSizeId = lstPSVM[0].ProducSizeId, ProductColorId = lstPCVM[0].ProductColorId, Stock = 0
                    };
                    //  6-1a-2.回7。
                }
            }
            // 6-0.系統在ViewComponent【ProductDetail】讀取讀取商品圖示清單:
            List <ProductImageListViewModel> lstPIVM = await IPRR.GetProductImageList(ProductId, 0, 1000);

            // 7.系統回傳View(new ProductDetailMallViewModel { Product=3讀取值, ProductSize=4傳回值, ProductColor=5傳回值, ProductStock=6傳回值 })。
            //int? MemberLevelId = -1;
            //if (HttpContext.Session.GetInt32("MemberLevelId") != null)
            //    MemberLevelId = HttpContext.Session.GetInt32("MemberLevelId");
            //else
            //    MemberLevelId = -1;
            return(View(new ProductDetailMallViewModel {
                Product = PLVM, ProductSize = lstPSVM, ProductColor = lstPCVM, ProductStock = PSLVM, ProductImage = lstPIVM, MemberLevelId = MemberLevelId
            }));
        }
Example #3
0
        public List <ProductStockListViewModel> GetProductsStock()
        {
            List <ProductStockListViewModel> productList = new List <ProductStockListViewModel>();

            _unitOfWork.Repository <ProductStock>().GetAllInclude(x => x.Product).ToList().ForEach(x =>
            {
                ProductStockListViewModel productStock = new ProductStockListViewModel
                {
                    Id           = x.Id,
                    ProductId    = x.ProductId,
                    ModifiedDate = x.ModifiedDate,
                    AddedDate    = x.AddedDate,
                    InQuantity   = x.InQuantity,
                    ProductName  = x.Product.Name,
                    OutQuantity  = x.OutQuantity,
                    Remarks      = x.Remarks,
                    InStock      = x.InQuantity - x.OutQuantity
                };
                productList.Add(productStock);
            });
            return(productList);
        }