public void addNewPhoneNumber(string Number) { AContactDetail aCD = new PhoneContactDetail() { phoneNumber = Number, ContactName = this.Fullname, }; AddContact(aCD); //aCD.makePrimary(); }
//private DataAccess.Database _database; //public DataAccess.Database database //{ // get // { // return _database; // } // set // { // _database = value; // DState.IO = value; // DState.NeedsUpdating = true; // } //} public static Championship copyChampionship(string newChampionshipName, Championship origonalChampionship, DataAccess.Database Connection, Team team = null) { Championship newChamp = new Championship(newChampionshipName, origonalChampionship.AgeDateReference); newChamp.Location = origonalChampionship.Location; newChamp.Locked = origonalChampionship.Locked; newChamp.ShortName = origonalChampionship.ShortName; newChamp._FixedName = origonalChampionship.FixedName; Connection.Add <Championship>(newChamp); // Restrictions foreach (Group res in origonalChampionship.Groups) { newChamp.addGroup(Group.CopyGroup(res)); } #if (!TeamTesting) // Teams (and schools) Team[] teams; if (team == null) { teams = origonalChampionship.Teams; } else { teams = new Team[] { team } }; foreach (Team t in teams) { Team t2 = new Team(t.Name, newChamp) { ShortName = t.ShortName }; newChamp.addTeam(t2); foreach (School sch in t.HasSchools) { School s2 = new DM.School(sch.Name); s2.ShortName = sch.ShortName; Connection.Add <School>(s2); t2.AddSchool(s2, Connection); foreach (var athlete in origonalChampionship.DState.IO.GetAll <Athlete>().Where(a => a.Attends == sch)) { // copy athlete Athlete a = new Athlete( ) { FirstName = athlete.FirstName, MiddleName = athlete.MiddleName, LastName = athlete.LastName, PreferredName = athlete.PreferredName, Attends = s2, GlobalAthleteID = athlete.GlobalAthleteID, DateOfBirth = athlete.DateOfBirth, Gender = athlete.Gender, Suffix = athlete.Suffix, Title = athlete.Title }; Connection.Add <Person>(a); // copy athlete notes foreach (var note in athlete._Notes) { if (note.GetType( ) == typeof(ConfidentialNote)) { a.AddNote(new ConfidentialNote(note)); } else if (note.GetType( ) == typeof(PublicNote)) { a.AddNote(new PublicNote((PublicNote)note)); } // 2017-03-26 // Deliberately not copying availability information between championships! // this could be a mistake. //else if ( note.GetType() == typeof(DeclaredAvailibilityInformation )) // a.AddNote( new DeclaredAvailibilityInformation( (DeclaredAvailibilityInformation)note ) ); else if (note.GetType( ) == typeof(PowerOfTenResult)) { a.AddNote(new PowerOfTenResult((PowerOfTenResult)note)); } else if (note.GetType( ) == typeof(PreviousResult)) { a.AddNote(new PreviousResult((PreviousResult)note)); } } // copy athlete contacts foreach (var contact in athlete.Contacts) { AContactDetail detail = null; if (contact is EmailContactDetail) { detail = new EmailContactDetail(((EmailContactDetail)contact).EmailAddress, contact.ContactName); } if (contact is AddressContactDetail) { detail = new AddressContactDetail( contact.ContactName, ((AddressContactDetail)contact).FirstLine, ((AddressContactDetail)contact).SecondLine, ((AddressContactDetail)contact).ThirdLine, ((AddressContactDetail)contact).FourthLine, ((AddressContactDetail)contact).PostCode); } if (contact is PhoneContactDetail) { detail = new PhoneContactDetail( ) { ContactName = contact.ContactName, phoneNumber = ((PhoneContactDetail)contact).phoneNumber } } ; if (contact is MobileContactDetail) { detail = new MobileContactDetail( ) { ContactName = contact.ContactName, phoneNumber = ((MobileContactDetail)contact).phoneNumber } } ; if (detail != null) { a.AddContact(detail); } } } origonalChampionship.DState.IO.DeleteRange <Person>( origonalChampionship.DState.IO.GetAll <Athlete>( ).Where(a => a.Attends == sch).ToArray()); } } #endif // Events (not competitors or results) foreach (AEvent Event in origonalChampionship.listAllEvents( )) { AEvent.CopyEvent(Event, newChamp); } // Custom Data CustomData.CopyCustomData(origonalChampionship.CustomDataStore, newChamp); newChamp.Save( ); return(newChamp); }