public void AddAthletes(List <Athlete> athletes) { if (athletes.Any()) { athletes.ForEach(_x => { _x.Start(); Athletes.Add(_x); }); } }
public AthleteDetailsVM(IDataAccessService DbAccess, FitLogImporter FitLogImporter, GpxImporter GpxImporter) { _Logger = NLog.LogManager.GetCurrentClassLogger(); _DbAccess = DbAccess; _FitLogImporter = FitLogImporter; _GpxImporter = GpxImporter; Messenger.Default.Register <NotificationMessage <IList <AthleteEntity> > >(this, message => { if (message.Notification == MessengerNotifications.LOADED) { if (message.Content == null) { Athletes = new ObservableCollection <AthleteEntity>(); } else { Athletes = new ObservableCollection <AthleteEntity>(message.Content); } } }); Messenger.Default.Register <NotificationMessage <ImporterTypeEnum> >(this, message => { if (message.Notification == MessengerNotifications.IMPORT) { ImportDialog(message.Content); } }); Messenger.Default.Register <NotificationMessage <AthleteEntity> >(this, message => { if (message.Notification == MessengerNotifications.NEW) { var athlete = message.Content; Athletes.Add(athlete); SelectedAthlete = athlete; } }); Messenger.Default.Register <NotificationMessage <ACTION_TYPE> >(this, message => { if (message.Notification == MessengerNotifications.ASK_FOR_ACTION && message.Content == ACTION_TYPE.DELETE_SELECTED_ACTIVITIES) { DispatcherHelper.CheckBeginInvokeOnUI(() => { var toRemove = new List <ActivityEntity>(SelectedActivities); foreach (var activity in toRemove) { _SelectedAthlete.Activities.Remove(activity); } }); } }); }
/// <summary> /// Create and add a new athlete to the athletes list. Save the list. /// </summary> /// <param name="key">athlete key</param> /// <param name="name">athlete name</param> /// <param name="runningNumbers">athlete running numbers</param> /// <param name="handicap">athlete handicap</param> /// <param name="firstTimer">first timer flag</param> public void AddNewAthlete( int key, string name, string handicap, bool firstTimer) { AthleteSeasonDetails newAthlete = new AthleteSeasonDetails( key, name); Athletes.Add(newAthlete); this.athleteData.SaveAthleteSeasonData(Name, Athletes); this.AthletesChangedEvent?.Invoke(this, new EventArgs()); this.AthleteCollectionChangedEvent?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Create and add a new athlete to the athletes list. Save the list. /// </summary> /// <param name="key">athlete key</param> /// <param name="name">athlete name</param> /// <param name="runningNumbers">athlete running numbers</param> /// <param name="handicap">athlete handicap</param> /// <param name="firstTimer">first timer flag</param> public void AddNewAthlete( int key, string name, string handicap, bool firstTimer) { AthleteSeasonDetails newAthlete = new AthleteSeasonDetails( key, name, this.resultsConfigurationManager); Athletes.Add(newAthlete); this.athleteData.SaveAthleteSeasonData(Name, Athletes); this.AthletesChangedEvent?.Invoke(this, new EventArgs()); }
public void ReadTeamsAndSchools( ) { Schools.Clear( ); Teams.Clear( ); Athletes.Clear( ); doc.Load(FilePath); foreach (XmlElement teams in doc.SelectSingleNode("EntryForm").SelectSingleNode("Teams").ChildNodes) { IIdentityStorage t = new IIdentityStorage(); t.ShortName = teams.InnerText; t.item = FileIO.FConnFile.GetFileDetails( ).IO.GetAll <DM.Team> ( ).Where(te => te.ShortName.Trim( ) == t.ShortName.Trim( )).FirstOrDefault( ); t.processor = this; Teams.Add(t); } foreach (XmlElement school in doc.SelectSingleNode("EntryForm").SelectSingleNode("Schools").ChildNodes) { IIdentityStorage t = new IIdentityStorage(); t.ShortName = school.InnerText; t.item = FileIO.FConnFile.GetFileDetails( ).IO.GetAll <DM.School> ( ).Where(te => te.ShortName.Trim() == t.ShortName.Trim()).FirstOrDefault( ); t.isSchool = true; t.processor = this; Schools.Add(t); } foreach (XmlElement athlete in doc.SelectSingleNode("EntryForm").SelectSingleNode("Entries").ChildNodes) { try { AthleteStorage a = new AthleteStorage(); a.Name = athlete.Attributes["Name"].Value.ToString( ).Replace(" ", " "); a.DateOfBirth = DateTime.Parse(athlete.Attributes["DateOfBirth"].Value); a.School = FileIO.FConnFile.GetFileDetails( ).IO.GetAll <DM.School> ( ).Where(te => te.ShortName.Trim( ) == athlete.Attributes["SchoolCode"].Value.Trim( )).FirstOrDefault( ); a.Team = FileIO.FConnFile.GetFileDetails( ).IO.GetAll <DM.Team> ( ).Where(te => te.ShortName.Trim( ) == athlete.Attributes["TeamCode"].Value.Trim( )).FirstOrDefault( ); if (athlete.Attributes["GlobalID"].Value != "") { a.GlobalID = int.Parse(athlete.Attributes["GlobalID"].Value); } if (athlete.Attributes["CategoryCode"].Value.Contains("B")) { a.Gender = DM.Gender.Male; } else { a.Gender = DM.Gender.Female; } a.EventCodes = new List <string> ( ); if (athlete.SelectSingleNode("Events").HasChildNodes) { foreach (XmlElement ev in athlete.SelectSingleNode("Events").ChildNodes) { a.EventCodes.Add(ev.Attributes["EventCode"].Value); } } Athletes.Add(a); Console.WriteLine("Athlete Read: " + a.Name); } catch (Exception ex) { MessageBox.Show("Failed to read " + athlete.Attributes["Name"].Value.ToString( ) + "\n" + ex.Message); continue; } } Wizard.changeHappend( ); }