Exemple #1
0
        public ActionResult UpdateProduct(int productID)
        {
            ProductDO item = null;
            ProductPO display = null;
            ActionResult response = RedirectToAction("Index", "Home");

            //Available to all roles
            if (Session["RoleID"] != null)
            {
                try
                {
                    item = _dataAccess.ReadIndividualProduct(productID);
                    display = ProductMappers.ProductDOtoPO(item);
                }

                catch (Exception exception)
                {
                    ErrorLogger.LogExceptions(exception);
                    response = View(productID);
                }

                finally
                { }

                response = View(display);
            }

            else
            {
                response = RedirectToAction("Index", "Home");
            }

            return response;
        }
Exemple #2
0
        //Get product names for dropdown menu in Order view:
        public List <ProductPO> GetListOfProducts()
        {
            List <ProductDO> allProducts    = _productDataAccess.ReadAllProducts();
            List <ProductPO> mappedProducts = new List <ProductPO>();

            //Maps all properties, not just the name:
            foreach (ProductDO dataObject in allProducts)
            {
                mappedProducts.Add(ProductMappers.ProductDOtoPO(dataObject));
            }

            return(mappedProducts);
        }
Exemple #3
0
        // GET: Product
        public ActionResult Index()
        {
            List<ProductDO> allProducts = null;
            List<ProductPO> mappedProducts = null;

            try
            {
                //Getting the index:
                allProducts = _dataAccess.ReadAllProducts();
                mappedProducts = new List<ProductPO>();

                foreach (ProductDO dataObject in allProducts)
                {
                    mappedProducts.Add(ProductMappers.ProductDOtoPO(dataObject));
                }

                //For most common manufacturer:
                List<ProductDO> productsList = new List<ProductDO>();
                List<string> manufacturerList = new List<string>();
                List<string> mostCommonManufacturer;

                foreach (ProductDO dataObject in productsList = _dataAccess.ReadAllProducts())
                {
                    string manufacturerString = dataObject.Manufacturer;
                    //Add each manufacturer to the list:
                    manufacturerList.Add(manufacturerString);
                }

                mostCommonManufacturer = _businessLayerAccess.GetMostFrequentManufacturer(manufacturerList);
                ViewBag.mostCommonManufacturer = string.Join(", ", mostCommonManufacturer.ToArray());
            }

            catch (Exception exception)
            {
                ErrorLogger.LogExceptions(exception);
            }

            finally
            { }

            return View(mappedProducts);
        }