public void AddPhoneNumber(int AthleteID, string PhoneNumber) { if (string.IsNullOrWhiteSpace(PhoneNumber)) { return; } if (AthleteID == 0) { return; } // existing athlete Athlete Athlete = getAthlete(AthleteID); if (Athlete == null) { return; } Athlete.AddContact(new PhoneContactDetail( ) { phoneNumber = System.Web.HttpUtility.UrlDecode(PhoneNumber) }); }
public void AddEmail(int AthleteID, string EmailAddress) { if (string.IsNullOrWhiteSpace(EmailAddress)) { return; } if (AthleteID == 0) { return; } // existing athlete Athlete Athlete = getAthlete(AthleteID); if (Athlete == null) { return; } Athlete.AddContact(new EmailContactDetail( ) { EmailAddress = System.Web.HttpUtility.UrlDecode(EmailAddress) }); }
private void Button_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "XML Data Set (.xml)|*.xml"; if (openFileDialog.ShowDialog( ) != true) { return; } XmlDocument doc = new XmlDocument(); doc.Load(openFileDialog.FileName); int current_Person_ID = 0; Athlete athlete = new Athlete(); //CSDB context = ChampionshipSolutions.FileIO.FConnFile.getContext(); foreach (XmlElement row in doc.ChildNodes[1].ChildNodes [1].ChildNodes) { //if (current_Person_ID == 0) current_Person_ID = int.Parse(row.Attributes["People_ID"].Value); if (current_Person_ID != int.Parse(row.Attributes ["People_ID"].Value)) { //FileIO.FConnFile.SaveChanges(); // new person athlete = new Athlete( ); athlete.ID = int.Parse(row.Attributes ["People_ID"].Value); current_Person_ID = athlete.ID; athlete.FirstName = row.Attributes ["FirstName"].Value; athlete.MiddleName = row.Attributes ["MiddleName"].Value; athlete.LastName = row.Attributes ["LastName"].Value; System.Diagnostics.Debug.WriteLine("New Athlete: " + athlete.Fullname); athlete.Gender = (Gender)int.Parse(row.Attributes ["Gender"].Value); if (!string.IsNullOrWhiteSpace(row.Attributes ["DateOfBirth"].Value)) { athlete.DateOfBirth = DateTime.Parse(row.Attributes ["DateOfBirth"].Value); } if (!string.IsNullOrWhiteSpace(row.Attributes ["phoneNumber"].Value)) { athlete.AddContact(new PhoneContactDetail( ) { phoneNumber = row.Attributes ["phoneNumber"].Value }); } if (!string.IsNullOrWhiteSpace(row.Attributes ["SchoolCode"].Value)) { //athlete.Attends = context.Schools.ToArray( ).Where( s => s.ShortName == row.Attributes [ "SchoolCode" ].Value ).FirstOrDefault( ); athlete.Attends = FileIO.FConnFile.GetFileDetails().IO.GetAll <School>().ToArray( ).Where(s => s.ShortName == row.Attributes ["SchoolCode"].Value).FirstOrDefault( ); if (athlete.Attends == null) { System.Diagnostics.Debug.WriteLine("Failed to find school: " + row.Attributes ["School"].Value); } } FileIO.FConnFile.GetFileDetails( ).IO.Add <Person>(athlete); } PreviousResult pr = new PreviousResult(athlete, DateTime.Now); pr.Championship = row.Attributes ["Championship"].Value; pr.Venue = row.Attributes ["ChampionshipLocation"].Value; pr.Team = row.Attributes ["Team"].Value; pr.Event = row.Attributes ["Event"].Value; pr.Rank = row.Attributes ["Rank"].Value; if (!string.IsNullOrWhiteSpace(row.Attributes ["Value_RawValue"].Value)) { pr.Event = row.Attributes ["EventIfHeat"].Value; ResultValue rv = new ResultValue((ResultDisplayDescription)int.Parse(row.Attributes["Value_ValueType"].Value)); rv.setResult(int.Parse(row.Attributes ["Value_RawValue"].Value)); pr.ResultValue = rv.ToString( ); } athlete.AddNote(pr); //< FIELD FieldName = "School" DisplayLabel = "School" FieldType = "String" FieldClass = "TField" /> //< FIELD FieldName = "Event_ID" DisplayLabel = "Event_ID" FieldType = "Integer" FieldClass = "TField" /> //< FIELD FieldName = "VestNumber" DisplayLabel = "VestNumber" FieldType = "String" FieldClass = "TField" /> //< FIELD FieldName = "EventIDIfHeat" DisplayLabel = "EventIDIfHeat" FieldType = "Integer" FieldClass = "TField" /> //< FIELD FieldName = "FinalEventID" DisplayLabel = "FinalEventID" FieldType = "Integer" FieldClass = "TField" /> //< FIELD FieldName = "TypeDescriminator" DisplayLabel = "TypeDescriminator" FieldType = "Integer" FieldClass = "TField" /> //< FIELD FieldName = "ContactName" DisplayLabel = "ContactName" FieldType = "String" FieldClass = "TField" /> } //FileIO.FConnFile.SaveChanges( ); }