// Get all Dining Tables and populate as dropdown list items public async Task <List <SelectListItem> > GetAllTables() { var tables = await _table.GetAllTables(); List <SelectListItem> list = new List <SelectListItem>(); foreach (var table in tables) { list.Add(new SelectListItem { Text = table.TableNumber.ToString(), Value = table.Id.ToString() }); } return(list); }
// View all DiningTables as a list public async Task <IActionResult> ViewDiningTables() { var allTables = await _data.GetAllTables(); List <DiningTableDisplayModel> tables = new List <DiningTableDisplayModel>(); foreach (var table in allTables) { tables.Add(new DiningTableDisplayModel { Id = table.Id, TableNumber = table.TableNumber, Seats = table.Seats }); } return(View(tables)); }