public ActionResult GetByCategory(int categoryId) { var list = new List <ItemsListViewModel>(); foreach (var item in SItem.GetByCategory(categoryId)) { list.Add(new ItemsListViewModel() { CategoryName = SCategory.SelectById(item.CategoryId).Name, Name = item.Name, Quantity = item.Quantity, Value = item.Value, Id = item.Id }); } return(View(list)); }
// GET: Categories public ActionResult Index() { var list = new List <ItemsListViewModel>(); foreach (var item in SItem.GetAllItems()) { var category = SCategory.SelectById(item.CategoryId); list.Add(new ItemsListViewModel() { CategoryName = category == null ? string.Empty : category.Name, Name = item.Name, Quantity = item.Quantity, Value = item.Value, Id = item.Id }); } return(View(list)); }