Ejemplo n.º 1
0
        public async Task <List <ProductModel> > GetAllProductList()
        {
            List <ProductModel> pm             = new List <ProductModel>();
            List <Product>      productAllList = await productList.GetAllProductList();

            foreach (var product in productAllList)
            {
                pm.Add(new ProductModel()
                {
                    ProductId   = product.ProductId,
                    ProductName = product.ProductName,
                    UnitPrice   = product.UnitPrice,
                    Stock       = product.Stock,
                    Image       = "/Images/" + product.Image
                });
            }

            return(pm);
        }
Ejemplo n.º 2
0
        public async Task <List <ProductModel> > GetAllProductList()// db product model map to prodctModel
        {
            List <ProductModel>   pm             = new List <ProductModel>();
            IEnumerable <Product> productAllList = productList.GetAllProductList();

            foreach (var product in productAllList)
            {
                pm.Add(new ProductModel()
                {
                    ProductId         = product.ProductId,
                    ProductName       = product.ProductName,
                    UnitPrice         = product.UnitPrice,
                    Stock             = product.Stock,
                    Image             = "/Images/" + product.Image,
                    SelectedItemCount = 1
                });
            }

            return(pm);
        }
Ejemplo n.º 3
0
        public async Task <string> CheckAvalability(CheckoutModel[] ckModel)
        {
            string message = "";
            IEnumerable <Product> pdModel = plList.GetAllProductList();

            foreach (var cmodel in ckModel)
            {
                int stockCount = pdModel.Where(x => x.ProductId == cmodel.ProductId).FirstOrDefault().Stock;
                if (stockCount < cmodel.SelectedItemCount)
                {
                    if (message == "")
                    {
                        message = cmodel.ProductName + " is Out of stock";
                    }
                    else
                    {
                        message += " " + cmodel.ProductName + " is Out of stock";
                    }
                }
            }

            return(message);
        }