ICollection <SelectListItem> GetLocations() { List <SelectListItem> selectListItems = new List <SelectListItem>(); if (_repository != null) { var allLocations = _repository.GetLocations().ToList(); if (allLocations != null) { foreach (var location in allLocations) { selectListItems.Add(new SelectListItem { Text = location.Name, Value = location.Id.ToString() }); } } } return(selectListItems); }