Example #1
0
        public IActionResult Index()
        {
            var commodities = _commodityService.GetAllCommodities();

            var viewModel = new CommodityViewModel
            {
                Rows = commodities.Select(commodity => new CommodityRow
                {
                    Id    = commodity.Id,
                    Title = commodity.Title,
                    Price = commodity.Price
                }).OrderBy(commodity => commodity.Id).ToList()
            };

            return(View("Index", viewModel));
        }