Esempio n. 1
0
        // GET: Products
        public ActionResult Index()
        {
            try
            {
                List <Products> products = logic.GetAll();

                List <ProductsView> productsViews = products.Select(p => new ProductsView
                {
                    Id              = p.ProductID,
                    Name            = p.ProductName,
                    QuantityPerUnit = p.QuantityPerUnit,
                    Price           = (decimal)p.UnitPrice
                }).ToList();

                return(View(productsViews));
            }
            catch (Exception ex)
            {
                LogErrorsLogic logErrorsLogic = new LogErrorsLogic();
                logErrorsLogic.LogError(ex.Message);

                TempData["MensajeError"] = "There was a problem trying to load the products. " + ex.Message;
                return(RedirectToAction("Index", "Error", ex));
            }
        }
Esempio n. 2
0
        private void FillProductsGrid()
        {
            ProductsLogic productsLogic = new ProductsLogic();

            gridProductList.DataSource = productsLogic.GetAll();
            gridProductList.DataBind();
        }
Esempio n. 3
0
        public List <ProductsView> Get()
        {
            var products = productsLogic.GetAll();

            var productsViewList = products.Select(p => new ProductsView
            {
                Id              = p.ProductID,
                Name            = p.ProductName,
                QuantityPerUnit = p.QuantityPerUnit,
                Price           = (decimal)p.UnitPrice
            }).ToList();

            return(productsViewList);
        }