public void LoadData()
        {
            if (DataLoaded) { return; }
            IsBusy = true;

            var sports = _eventRepository.Sports();

            Scheduler.NewThread.Schedule(() =>
            {
                Debug.WriteLine(string.Format("Load Team Data - {0}", System.Threading.Thread.CurrentThread.ManagedThreadId));

                var teams = _eventRepository.Teams().Select(x =>
                                                                {
                                                                    var sport = sports.FirstOrDefault(s => s.Id == x.SportTypeId);
                                                                     var team = new Team(x, sport);
                                                                     return team;

                                                                 }).OrderBy(x => x.Name).ToList();

                HandleLoadedCallback(teams);
            });
        }
        private void EditSelectedTeam(Team team)
        {
            if (team == null) { return; }

            var url = string.Format("/Views/Teams/CreationPage.xaml?{0}={1}", QueryStringConstants.TeamId, team.Id);

            _navigationService.NavigateTo(new Uri(url, UriKind.RelativeOrAbsolute));
        }
        private void HandleLoadDataCallback(GameEvent gameEvent, Team team)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
                                                          {
                                                              GameEvent = gameEvent;
                                                              Team = team;

                                                              HasPlayers = Team.Players != null && Team.Players.Any();

                                                              if (Team.Players != null)
                                                              {
                                                                  Players = Team.Players.ToList();
                                                              }

                                                              DataLoaded = true;
                                                              IsBusy = false;
                                                          });
        }
        public void LoadData()
        {
            IsBusy = true;

            Scheduler.NewThread.Schedule(() =>
                                             {

                                                 _sports = _eventRepository.Sports();

                                                 var eventTypes = new List<EventType>
                                                                  {
                                                                      new EventType { Id = (int) Domain.Models.EventType.Practice, Name = Domain.Models.EventType.Practice.ToString() },
                                                                      new EventType { Id = (int) Domain.Models.EventType.Game, Name = Domain.Models.EventType.Game.ToString() }
                                                                  };

                                                 var teams = _eventRepository.Teams().Select(x =>
                                                                                 {
                                                                                     var sport = _sports.FirstOrDefault(s => s.Id == x.SportTypeId);
                                                                                     var team = new Team(x, sport);

                                                                                     return team;
                                                                                 }).ToList();

                                                 var fields = _eventRepository.Locations().Select(x => new Field(x)).ToList();

                                                 HandleDataLoadedCallback(teams, fields, eventTypes);

                                             });
        }
        public void LoadData(int eventId)
        {
            if (DataLoaded) { return; }

            Scheduler.NewThread.Schedule(() =>
            {

                var gameDto = _eventRepository.Event(eventId);
                var teamDto = _eventRepository.Teams().FirstOrDefault(x => x.Id == gameDto.Team.Id);
                var sportDto = _eventRepository.Sports().FirstOrDefault(x => x.Id == teamDto.SportTypeId);

                var gameEvent = new GameEvent(gameDto);
                var team = new Team(teamDto, sportDto);

                HandleLoadDataCallback(gameEvent, team);
            });
        }