// GET: Slot public ActionResult Index() { IList <SlotViewModel> slotsVm = new List <SlotViewModel>(); foreach (Slot s in _repository.GetSlots().ToList()) { var location = _repository.GetLocationById(s.LocationId); slotsVm.Add(new ViewModels.SlotViewModel() { SlotDetail = s, LocationName = location == null ? "" : location.Name }); } return(View(slotsVm)); }
private ICollection <SelectListItem> GetAvailableSlots() { var allSlots = _repository.GetSlots().ToList(); List <SelectListItem> selectListItems = new List <SelectListItem>(); if (allSlots != null) { foreach (var slot in allSlots) { selectListItems.Add(new SelectListItem { Text = slot.Name, Value = slot.Id.ToString() }); } } return(selectListItems); }