// 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)); } }
private void FillProductsGrid() { ProductsLogic productsLogic = new ProductsLogic(); gridProductList.DataSource = productsLogic.GetAll(); gridProductList.DataBind(); }
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); }