// 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)); }