public IActionResult Index() { var model = new GuitarBrandViewModel(); model.Brands = _items; return View(model); }
public IActionResult Index(GuitarBrandViewModel model) { model.Brands = _items; if (model.SelectedBrandId != 0) { model.SelectedBrand = (from b in _items where b.Value == model.SelectedBrandId.ToString() select new GuitarBrand { GuitarBrandId = int.Parse(b.Value), Name = b.Text }).FirstOrDefault(); } return View(model); }