Exemplo n.º 1
0
        public IActionResult SelectBrand(BrandViewModel vm)
        {
            BrandModel              brandModel   = new BrandModel(_db);
            ProductModel            productModel = new ProductModel(_db);
            List <Product>          items        = productModel.GetAllByBrand(vm.BrandId);
            List <ProductViewModel> vms          = new List <ProductViewModel>();

            if (items.Count > 0)
            {
                foreach (Product item in items)
                {
                    ProductViewModel mvm = new ProductViewModel();
                    mvm.Qty            = 0;
                    mvm.BrandId        = item.BrandId;
                    mvm.BrandName      = brandModel.GetName(item.BrandId);
                    mvm.Description    = item.Description;
                    mvm.Id             = item.Id;
                    mvm.PRODUCTNAME    = item.ProductName;
                    mvm.GRAPHICNAME    = item.GraphicName;
                    mvm.COSTPRICE      = Convert.ToDecimal(item.CostPrice);
                    mvm.MSRP           = Convert.ToDecimal(item.MSRP);
                    mvm.QTYONHAND      = item.QtyOnHand;
                    mvm.QTYONBACKORDER = item.QtyOnBackOrder;
                    vms.Add(mvm);
                }
                ProductViewModel[] myMenu = vms.ToArray();
                HttpContext.Session.Set <ProductViewModel[]>("menu", myMenu);
            }
            vm.SetBrands(HttpContext.Session.Get <List <Brand> >("brands"));
            return(View("Index", vm)); // need the original Index View here
        }
Exemplo n.º 2
0
        public IActionResult SelectCategory(BrandViewModel vm)
        {
            BrandModel              catModel  = new BrandModel(_db);
            ProductModel            menuModel = new ProductModel(_db);
            List <Products>         items     = menuModel.GetAllByCategory(vm.Id);
            List <ProductViewModel> vms       = new List <ProductViewModel>();

            if (items.Count > 0)
            {
                foreach (Products item in items)
                {
                    ProductViewModel mvm = new ProductViewModel();
                    mvm.BrandId   = item.BrandsId;
                    mvm.Qty       = 0;
                    mvm.BrandName = catModel.GetName(item.BrandsId);
                    //mvm.BrandName = item.Brand.Name;
                    mvm.Description    = item.Description;
                    mvm.Id             = item.Id;
                    mvm.ProductName    = item.ProductName;
                    mvm.GraphicName    = item.GraphicName;
                    mvm.CostPrice      = item.CostPrice;
                    mvm.MSRP           = item.MSRP;
                    mvm.QtyOnHand      = item.QtyOnHand;
                    mvm.QtyOnBackOrder = item.QtyOnBackOrder;

                    vms.Add(mvm);
                }
                ProductViewModel[] myMenu = vms.ToArray();
                HttpContext.Session.Set <ProductViewModel[]>("menu", myMenu);
            }
            vm.SetCategories(HttpContext.Session.Get <List <Brands> >("brands"));
            return(View("Index", vm)); // need the original Index View here
        }
Exemplo n.º 3
0
        public IActionResult SelectBrand(BrandViewModel vm)
        {
            BrandModel              brandModel = new BrandModel(_db);
            ProductModel            prodModel  = new ProductModel(_db);
            List <Product>          items      = prodModel.GetAllByBrand(vm.BrandId);
            List <ProductViewModel> vms        = new List <ProductViewModel>();

            if (items.Count > 0)
            {
                foreach (Product item in items)
                {
                    ProductViewModel mvm = new ProductViewModel();
                    mvm.Qty            = 0;
                    mvm.BrandId        = item.BrandId;
                    mvm.BrandName      = brandModel.GetName(item.BrandId);
                    mvm.GraphicName    = item.GraphicName;
                    mvm.ProductName    = item.ProductName;
                    mvm.MSRP           = item.MSRP;
                    mvm.QtyOnHand      = item.QtyOnHand;
                    mvm.QtyOnBackOrder = item.QtyOnBackOrder;
                    mvm.Description    = item.Description;
                    mvm.Id             = item.Id;
                    mvm.CostPrice      = item.CostPrice;

                    vms.Add(mvm);
                }
                ProductViewModel[] myProduct = vms.ToArray();
                HttpContext.Session.Set <ProductViewModel[]>("product", myProduct);
            }
            vm.SetBrands(HttpContext.Session.Get <List <Brand> >("brands"));
            return(View("Index", vm)); // need the original Index View here
        }
        public IActionResult SelectBrand(BrandViewModel vm)
        {
            BrandModel              bmModel = new BrandModel(_db);
            ProductModel            pModel  = new ProductModel(_db);
            List <Product>          items   = pModel.GetAllByBrand(vm.BrandId);
            List <ProductViewModel> vms     = new List <ProductViewModel>();

            if (items.Count > 0)
            {
                foreach (Product pr in items)
                {
                    ProductViewModel pvm = new ProductViewModel();
                    pvm.Qty            = 0;
                    pvm.BrandId        = pr.BrandId;
                    pvm.Id             = pr.Id; // Id is a string
                    pvm.BrandName      = bmModel.GetName(pr.BrandId);
                    pvm.ProductName    = pr.ProductName;
                    pvm.GraphicName    = pr.GraphicName;
                    pvm.CostPrice      = pr.CostPrice;
                    pvm.MSRP           = pr.MSRP;
                    pvm.QtyOnHand      = pr.QtyOnHand;
                    pvm.QtyOnBackOrder = pr.QtyOnBackOrder;
                    pvm.Description    = pr.Description;
                    vms.Add(pvm);
                }
                ProductViewModel[] myProducts = vms.ToArray();
                HttpContext.Session.Set <ProductViewModel[]>(SessionVariables.Catalogue, myProducts);
            }
            vm.SetBrands(HttpContext.Session.Get <List <Brand> >(SessionVariables.Brands));
            return(View("Index", vm));
        }
Exemplo n.º 5
0
        public IActionResult SelectBrand(BrandViewModel vm)
        {
            BrandModel              brandModel        = new BrandModel(_db);
            ProductModel            productModel      = new ProductModel(_db);
            List <Product>          products          = productModel.GetAllByBrand(vm.BrandId);
            List <ProductViewModel> productViewModels = new List <ProductViewModel>();

            if (products.Count > 0)
            {
                foreach (Product product in products)
                {
                    ProductViewModel productViewModel = new ProductViewModel();
                    productViewModel.Qty            = 0;
                    productViewModel.QtyOnBackOrder = product.QtyOnBackOrder;
                    productViewModel.QtyOnHand      = product.QtyOnHand;
                    productViewModel.Description    = product.Description;
                    productViewModel.Id             = product.Id;
                    productViewModel.BrandName      = brandModel.GetName(product.BrandId);
                    productViewModel.GraphicName    = product.GraphicName;
                    productViewModel.CostPrice      = product.CostPrice;
                    productViewModel.MSRP           = product.MSRP;
                    productViewModel.BrandId        = product.BrandId;
                    productViewModel.ProductName    = product.ProductName;
                    productViewModels.Add(productViewModel);
                }
                ProductViewModel[] myItems = productViewModels.ToArray();
                HttpContext.Session.Set <ProductViewModel[]>(SessionVars.Items, myItems);
            }
            vm.SetBrands(HttpContext.Session.Get <List <Brand> >(SessionVars.Brands));
            return(View("Index", vm));
        }
Exemplo n.º 6
0
        public IActionResult SelectBrand(CatalogueViewModel vm)
        {
            BrandModel              brandModel   = new BrandModel(_db);
            ProductModel            productModel = new ProductModel(_db);
            List <Product>          items        = productModel.GetAllByBrand(vm.BrandId);
            List <ProductViewModel> vms          = new List <ProductViewModel>();

            if (items.Count > 0)
            {
                foreach (Product item in items)
                {
                    ProductViewModel mvm = new ProductViewModel();
                    mvm.Qty         = 0;
                    mvm.BrandId     = item.BrandId;
                    mvm.BrandName   = brandModel.GetName(item.BrandId);
                    mvm.ProductName = item.ProductName;

                    mvm.Description    = item.Description;
                    mvm.GraphicName    = item.GraphicName;
                    mvm.CostPrice      = item.CostPrice;
                    mvm.MSRP           = item.MSRP;
                    mvm.QtyOnHand      = item.QtyOnHand;
                    mvm.QtyOnBackOrder = item.QtyOnBackOrder;

                    mvm.Id             = item.Id;
                    mvm.HP             = item.HP;
                    mvm.ATTACK         = item.Attack;
                    mvm.DEFENCE        = item.Defence;
                    mvm.SPECIALATTACK  = item.SpecialAttack;
                    mvm.SPECIALDEFENCE = item.SpecialDefence;
                    mvm.SPEED          = item.Speed;
                    vms.Add(mvm);
                }
                ProductViewModel[] myCat = vms.ToArray();
                HttpContext.Session.SetObject(SessionVars.Catalogue, myCat);
            }
            vm.SetBrands(HttpContext.Session.GetObject <List <Brand> >(SessionVars.Brands));
            return(View("Index", vm));
        }
Exemplo n.º 7
0
        public void GetAllProducts()
        {
            BrandModel              brandModel   = new BrandModel(_db);
            ProductModel            productModel = new ProductModel(_db);
            List <Product>          items        = productModel.GetAll();
            List <ProductViewModel> pvml         = new List <ProductViewModel>();

            if (items.Count > 0)
            {
                foreach (Product item in items)
                {
                    ProductViewModel pvm = new ProductViewModel();
                    pvm.Qty         = 0;
                    pvm.BrandId     = item.BrandId;
                    pvm.BrandName   = brandModel.GetName(item.BrandId);
                    pvm.ProductName = item.ProductName;

                    pvm.Description    = item.Description;
                    pvm.GraphicName    = item.GraphicName;
                    pvm.CostPrice      = item.CostPrice;
                    pvm.MSRP           = item.MSRP;
                    pvm.QtyOnHand      = item.QtyOnHand;
                    pvm.QtyOnBackOrder = item.QtyOnBackOrder;

                    pvm.Id             = item.Id;
                    pvm.HP             = item.HP;
                    pvm.ATTACK         = item.Attack;
                    pvm.DEFENCE        = item.Defence;
                    pvm.SPECIALATTACK  = item.SpecialAttack;
                    pvm.SPECIALDEFENCE = item.SpecialDefence;
                    pvm.SPEED          = item.Speed;
                    pvml.Add(pvm);
                }
                ProductViewModel[] myCat = pvml.ToArray();
                HttpContext.Session.SetObject("catalogue", myCat);
            }
        }
Exemplo n.º 8
0
        // to get the detial of product
        public IActionResult SelectBrand(BrandViewModel brandVm)
        {
            BrandModel              brandModel          = new BrandModel(_db);
            ProductModel            prodModel           = new ProductModel(_db);
            List <Product>          productsListByBrand = prodModel.GetByBrand(brandVm.BrandId);
            List <ProductViewModel> prodVMList          = new List <ProductViewModel>();

            if (productsListByBrand.Count > 0)
            {
                // give me the details of each product by foreach loop
                foreach (Product prod in productsListByBrand)
                {
                    ProductViewModel prodVM = new ProductViewModel();

                    prodVM.QtyOnHand      = 0;
                    prodVM.BrandId        = prod.BrandId;
                    prodVM.BrandName      = brandModel.GetName(prod.BrandId);
                    prodVM.Description    = prod.Description;
                    prodVM.CostPrice      = prod.CostPrice;
                    prodVM.Id             = prod.Id;
                    prodVM.GraphicName    = prod.GraphicName;
                    prodVM.MSRP           = prod.MSRP;
                    prodVM.ProductName    = prod.ProductName;
                    prodVM.QtyOnHand      = prod.QtyOnHand;
                    prodVM.QtyOnBackOrder = prod.QtyOnBackOrder;

                    prodVMList.Add(prodVM);
                }


                ProductViewModel[] myProdArray = prodVMList.ToArray();
                HttpContext.Session.Set <ProductViewModel[]>("productSession", myProdArray);
            }
            brandVm.SetBrands(HttpContext.Session.Get <List <Brands> >("brandSession"));
            return(View("Index", brandVm));
        }