/// <summary> /// Initialises a new instance of the Tennis_Management_Software.Student class. /// </summary> public Student(uint id, string name, string surname, PersonGender gender, string phoneNumber, string homePhoneNumber, string homeAddress, DateTime dateOfBirth, string email, StudentSkillLevel studentLevel, List <StudentTimetable> studentTimetableList, string fatherWorkAddress, string motherWorkAddress, string fatherPhoneNumber, string motherPhoneNumber, uint studentTennisAssociationNum, uint healthCertificateNum) { this.ID = id; this.Name = name; this.Surname = surname; this.Gender = gender; this.PhoneNumber = phoneNumber; this.HomePhoneNumber = homePhoneNumber; this.HomeAddress = homeAddress; this.DateOfBirth = dateOfBirth; this.Email = email; this.StudentLevel = studentLevel; this.FatherName = fatherWorkAddress; this.MotherName = motherWorkAddress; this.FatherPhoneNumber = fatherPhoneNumber; this.MotherPhoneNumber = motherPhoneNumber; this.TennisAssociationNum = studentTennisAssociationNum; this.HealthCertificateNum = healthCertificateNum; TennisPlayerInfo = new TennisPlayerInformation <StudentTimetable>(studentTimetableList); }
private static double CalculateListMaleQuota(MeetingElectionCandidates candidates, PersonGender nextCandidateGender) { if (candidates.Count < 1) { return(0.5); // Division by zero protection, here and in caller } double malesTotal = 0.0; foreach (MeetingElectionCandidate candidate in candidates) { if (candidate.Person.Gender == PersonGender.Male) { malesTotal += 1.0; } } if (nextCandidateGender == PersonGender.Male) { malesTotal += 1.0; } return(malesTotal / (candidates.Count + 1.0)); }
public void Constructor() { PersonGender personGender; personGender = new PersonGender(1, "Test", 1, DataContextTest.GetOneDataContext()); Assert.IsNotNull(personGender); }
public Student(StudentType Type, String Name, PersonGender Gender, DateTime TimeStamp) { this.Type = Type; this.Name = Name; this.Gender = Gender; this.TimeStamp = TimeStamp; }
// Create a new patient and pass it to the meta layer for insertion into the database. public bool AddPatient(String firstName, String lastName, String addressLine1, String addressLine2, String city, String county, String postCode, DateTime dateOfBirth, String emailAddress, PersonGender gender, String maritalStatus, String telephoneNumber) { // Create a new member of staff with all of their details Patient newPatient = new Patient(); newPatient.FirstName = EncodeMySql(firstName); newPatient.LastName = EncodeMySql(lastName); newPatient.AddressLine1 = EncodeMySql(addressLine1); newPatient.AddressLine2 = EncodeMySql(addressLine2); newPatient.City = EncodeMySql(city); newPatient.County = EncodeMySql(county); newPatient.PostCode = EncodeMySql(postCode); newPatient.DateOfBirth = dateOfBirth; newPatient.EmailAddress = EncodeMySql(emailAddress); newPatient.TelephoneNumber = EncodeMySql(telephoneNumber); newPatient.MaritalStatus = EncodeMySql(maritalStatus); newPatient.Gender = gender; return BusinessMetaLayer.AddPatientDetails(newPatient); }
public int CreatePerson(string name, string email, string phone, string street, string postalCode, string city, int countryId, DateTime birthDate, PersonGender gender) { using (DbConnection connection = GetMySqlDbConnection()) { connection.Open(); DbCommand command = GetDbCommand("CreatePerson", connection); command.CommandType = CommandType.StoredProcedure; AddParameterWithName(command, "name", name); AddParameterWithName(command, "email", email); AddParameterWithName(command, "passwordHash", string.Empty); AddParameterWithName(command, "phoneNumber", phone); AddParameterWithName(command, "street", street); AddParameterWithName(command, "postalCode", postalCode); AddParameterWithName(command, "city", city); AddParameterWithName(command, "countryId", countryId); AddParameterWithName(command, "birthdate", birthDate); AddParameterWithName(command, "genderId", (int)gender); int personId = Convert.ToInt32(command.ExecuteScalar()); return(personId); } }
public Person(string Name, string LastName, int Age, PersonGender Gender) { this.Name = Name; this.LastName = Name; this.Age = Age; this.Gender = Gender; }
private PersonGender GetPersonGender(Boolean refresh) { if (_personGender.IsNull() || refresh) { _personGender = new PersonGender(1, "Test", 1, DataContextTest.GetOneDataContext()); } return(_personGender); }
public async Task <IEnumerable <Person> > ListByGenderAsync(PersonGender gender, CancellationToken cancellationToken) { var dto = await _dataService.FetchAsync(cancellationToken); var people = dto.Where(p => p.Gender == gender).Select(p => _mapper.Map(p)).ToList(); return(people); }
/// <summary> /// Returns true if Person instances are equal /// </summary> /// <param name="other">Instance of Person to be compared</param> /// <returns>Boolean</returns> public bool Equals(Person other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( FirstName == other.FirstName || FirstName != null && FirstName.Equals(other.FirstName) ) && ( Surname == other.Surname || Surname != null && Surname.Equals(other.Surname) ) && ( DateOfBirth == other.DateOfBirth || DateOfBirth != null && DateOfBirth.Equals(other.DateOfBirth) ) && ( PersonGender == other.PersonGender || PersonGender.Equals(other.PersonGender) ) && ( MatchId == other.MatchId || MatchId != null && MatchId.Equals(other.MatchId) ) && ( AllocatePersonId == other.AllocatePersonId || AllocatePersonId != null && AllocatePersonId.Equals(other.AllocatePersonId) ) && ( Email == other.Email || Email != null && Email.Equals(other.Email) ) && ( TelephoneNumber == other.TelephoneNumber || TelephoneNumber != null && TelephoneNumber.Equals(other.TelephoneNumber) ) && ( ExtSystemId == other.ExtSystemId || ExtSystemId != null && ExtSystemId.Equals(other.ExtSystemId) )); }
public MembershipEvent() { this.DateTime = DateTime.MinValue; this.DeltaCount = 0; this.PersonId = 0; this.OrganizationId = 0; this.GeographyId = 0; this.BirthYear = 0; this.Gender = PersonGender.Unknown; }
public static string Localized(ParticipantTitle title, PersonGender gender) { string genderString = gender.ToString(); if (gender == PersonGender.Unknown) { genderString = "Generic"; } return(Localized(title, genderString)); }
public CatsGroupedByOwnersGender(PersonGender ownersGender, IEnumerable <string> catNames) { if (catNames == null) { throw new ArgumentNullException(nameof(catNames)); } _ownersGender = ownersGender; _catNames = catNames; }
public MembershipEvent() { this.DateTime = Constants.DateTimeLow; this.DeltaCount = 0; this.PersonId = 0; this.OrganizationId = 0; this.GeographyId = 0; this.BirthYear = 0; this.Gender = PersonGender.Unknown; }
public PersonGenderList GetPersonGenders(IUserContext userContext) { IPersonGender gender = new PersonGender(1, "gender", 1, new DataContext(userContext)); PersonGenderList personGenderList = new PersonGenderList(); personGenderList.Add(gender); IPersonGender gender2 = new PersonGender(3, "gender2", 3, new DataContext(userContext)); personGenderList.Add(gender2); return(personGenderList); }
public MembershipEvent(DateTime dateTime, int personId, int organizationId, int geographyId, int birthYear, PersonGender gender, int deltaCount) { this.DateTime = dateTime; this.PersonId = personId; this.OrganizationId = organizationId; this.GeographyId = geographyId; this.BirthYear = birthYear; this.Gender = gender; this.DeltaCount = deltaCount; }
private Student ProcessStudentLine(string[] parameters) { StudentType type = (StudentType)Enum.Parse(typeof(StudentType), parameters[0]); string name = parameters[1]; PersonGender studentGender = (PersonGender)Enum.Parse(typeof(PersonGender), processStudentGender(parameters[2])); DateTime timeStamp = DateTime.ParseExact(parameters[3], DateFomat, System.Globalization.CultureInfo.InvariantCulture); return(CreateStudent(type, name, studentGender, timeStamp)); }
public MembershipEvent (DateTime dateTime, int personId, int organizationId, int geographyId, int birthYear, PersonGender gender, int deltaCount) { this.DateTime = dateTime; this.PersonId = personId; this.OrganizationId = organizationId; this.GeographyId = geographyId; this.BirthYear = birthYear; this.Gender = gender; this.DeltaCount = deltaCount; }
private static void ProcessUploadThread(object guidObject) { string guid = (string)guidObject; Documents documents = Documents.RecentFromDescription(guid); Document uploadedDoc = documents[0]; string data = string.Empty; int count = 0; using (StreamReader reader = uploadedDoc.GetReader(Encoding.UTF8)) { data = reader.ReadToEnd(); } string[] lines = data.Split('\n'); Random random = new Random(); foreach (string lineRaw in lines) { count++; string line = lineRaw.Trim(); string[] lineParts = line.Split('\t'); if (lineParts.Length < 12) { continue; } int percent = (count * 99) / lines.Length; if (percent == 0) { percent = 1; } GuidCache.Set(guid + "-Progress", percent); string name = lineParts[0] + " " + lineParts[1]; PersonGender gender = lineParts[2] == "male" ? PersonGender.Male : PersonGender.Female; DateTime dateOfBirth = DateTime.Parse(lineParts[7], new CultureInfo("en-US"), DateTimeStyles.None); Country country = Country.FromCode(lineParts[6]); Person newPerson = Person.Create(name, string.Empty, string.Empty, lineParts[8], lineParts[3], lineParts[4].Replace(" ", ""), lineParts[5], lineParts[6], dateOfBirth, gender); newPerson.NationalIdNumber = lineParts[9]; newPerson.Longitude = lineParts[10]; newPerson.Latitude = lineParts[11]; newPerson.AddParticipation(Organization.Sandbox, DateTime.Today.AddDays(random.Next(365))); } GuidCache.Set(guid + "-Progress", 100); }
public void SetPersonGender(int personId, PersonGender gender) { using (DbConnection connection = GetMySqlDbConnection()) { connection.Open(); DbCommand command = GetDbCommand("SetPersonGender", connection); command.CommandType = CommandType.StoredProcedure; AddParameterWithName(command, "personId", personId); AddParameterWithName(command, "genderId", (int)gender); command.ExecuteNonQuery(); } }
public static Person Create(string name, string email, string password, string phone, string street, string postal, string city, string countryCode, DateTime dateOfBirth, PersonGender gender) { BasicCountry country = null; if (countryCode.Length > 0) { country = Country.FromCode(countryCode); } // Clean data while (name.Contains(" ")) { name = name.Replace(" ", " "); } name = name.Trim(); email = email.ToLower().Trim(); phone = LogicServices.CleanNumber(phone); postal = postal.Replace(" ", "").Trim(); int personId = SwarmDb.GetDatabaseForWriting().CreatePerson(name, email, phone, street, postal, city, country == null ? 0 : country.Identity, dateOfBirth, gender); // Resolve the geography Person newPerson = FromIdentityAggressive(personId); // aggressive bypasses replication lag, avoids race condition newPerson.ResolveGeography(); // Generate the salted password hash and set it if (password.Length > 0) { newPerson.PasswordHash = Authentication.GenerateNewPasswordHash(personId, password); } else { newPerson.PasswordHash = string.Empty; // if no password, prevent matching to anything } // Return the finished Person object return(newPerson); }
public async Task ListByGenderAsync_Theory(PersonGender gender) { var repo = _provider.GetService <IPeopleRepository>(); var dataService = _provider.GetService <IDataService>(); var dtos = PeopleDtoMock.GetAllValidPeople(); dataService.FetchAsync(Arg.Is(CancellationToken.None)) .Returns(Task.FromResult(dtos)); var resp = await repo.ListByGenderAsync(gender, CancellationToken.None); Assert.NotNull(resp); Assert.Equal(dtos.Count(d => d.Gender == gender), resp.Count()); }
public BasicPerson (int personId, string passwordHash, string name, string email, string street, string postalCode, string cityName, int countryId, string phone, int geographyId, DateTime birthdate, PersonGender gender) { this.PersonId = personId; this.PasswordHash = passwordHash; this.Name = name; this.Email = email; this.Street = street; this.PostalCode = postalCode; this.CityName = cityName; this.CountryId = countryId; this.Phone = phone; this.GeographyId = geographyId; this.Birthdate = birthdate; this.Gender = gender; }
public BasicPerson(int personId, string passwordHash, string name, string email, string street, string postalCode, string cityName, int countryId, string phone, int geographyId, DateTime birthdate, PersonGender gender) { PersonId = personId; PasswordHash = passwordHash; Name = name; Email = email; Street = street; PostalCode = postalCode; CityName = cityName; CountryId = countryId; Phone = phone; GeographyId = geographyId; Birthdate = birthdate; Gender = gender; }
public BasicPerson(int personId, string passwordHash, string name, string email, string street, string postalCode, string cityName, int countryId, string phone, int geographyId, DateTime birthdate, PersonGender gender) { this.PersonId = personId; this.PasswordHash = passwordHash; this.Name = name; this.Email = email; this.Street = street; this.PostalCode = postalCode; this.CityName = cityName; this.CountryId = countryId; this.Phone = phone; this.GeographyId = geographyId; this.Birthdate = birthdate; this.Gender = gender; }
/// <summary> /// Initializes a new instance of the Tennis_Management_Software.Coach class. /// </summary> public Coach(uint id, string name, string surname, PersonGender gender, string email, string phoneNumber, string homePhoneNumber, string homeAddress, DateTime dateOfBirth, float hourlyPaymentRate, float extraHourlyPaymentRate, List <CoachTimetable> timetableList) { this.ID = id; this.Name = name; this.Surname = surname; this.Gender = gender; this.Email = email; this.PhoneNumber = phoneNumber; this.HomePhoneNumber = homePhoneNumber; this.HomeAddress = homeAddress; this.DateOfBirth = dateOfBirth; this.HourlyPaymentRate = hourlyPaymentRate; this.ExtraHourlyPaymentRate = extraHourlyPaymentRate; TennisPlayerInfo = new TennisPlayerInformation <CoachTimetable>(timetableList); }
public Person(string name, PersonGender gender, int age, List <Pet> pets = default(List <Pet>)) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException(nameof(name)); } if (pets == null) { pets = new List <Pet>(); } _name = name; _gender = gender; _age = age; _pets = pets; }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (FirstName != null) { hashCode = hashCode * 59 + FirstName.GetHashCode(); } if (Surname != null) { hashCode = hashCode * 59 + Surname.GetHashCode(); } if (DateOfBirth != null) { hashCode = hashCode * 59 + DateOfBirth.GetHashCode(); } hashCode = hashCode * 59 + PersonGender.GetHashCode(); if (MatchId != null) { hashCode = hashCode * 59 + MatchId.GetHashCode(); } if (AllocatePersonId != null) { hashCode = hashCode * 59 + AllocatePersonId.GetHashCode(); } if (Email != null) { hashCode = hashCode * 59 + Email.GetHashCode(); } if (TelephoneNumber != null) { hashCode = hashCode * 59 + TelephoneNumber.GetHashCode(); } if (ExtSystemId != null) { hashCode = hashCode * 59 + ExtSystemId.GetHashCode(); } return(hashCode); } }
public string GetListOfStudents(StudentType Type, PersonGender Gender) { string listOfStudents = ""; foreach (Student student in this.StudentsByType[Type]) { if (student.GetGender() == Gender) { listOfStudents = String.Join( Environment.NewLine, listOfStudents, "", student.ToString()); } } if (listOfStudents.Length == 0) { listOfStudents = "No results found"; } return(listOfStudents); }
internal AuthTicket( int id, long?facebookId, MailAddressItem email, string firstName, string lastName, string nickName, PersonGender gender, DateTime?birthday, PhoneGroupItem phones) { Id = id; FacebookId = facebookId; Email = email; FirstName = firstName; LastName = lastName; NickName = nickName; Gender = gender; Birthday = birthday; Phones = phones; }
/// <summary> /// get all celebrities /// </summary> /// <returns></returns> public List <Celebrity> GetAllCelebrities() { List <Celebrity> listOfCelebs = null; try { List <string> celebsIds = ScrapeAllCelebsIds(); if (celebsIds.Count > 0) { listOfCelebs = new List <Celebrity>(); foreach (string id in celebsIds) { string url = String.Format(CELEB_MAIN_URL, id); HtmlDocument _mainHtmlPage = LoadHtml(url); string celebName = _mainHtmlPage.DocumentNode.SelectSingleNode("//*[@class='name-overview-widget__section']/h1/span").InnerText; string role = _mainHtmlPage.DocumentNode.SelectSingleNode("//*[@class='name-overview-widget__section']/div/a/span").InnerText; PersonGender gender = role.Contains("Actress") ? PersonGender.FEMALE : PersonGender.MALE; //if acctress must be female, else male - but if not actress I can't decide, it takes most of the cases DateTime birthDate = DateTime.Parse(_mainHtmlPage.DocumentNode.SelectSingleNode("//*[@id='name-born-info']/time").Attributes["datetime"].Value); string Photo = _mainHtmlPage.DocumentNode.SelectSingleNode("//*[@id='name-poster']").Attributes["src"].Value; Celebrity celeb = new Celebrity { Id = id, Name = celebName, DateOfBirth = birthDate, Gender = gender, Role = role, Photo = Photo }; listOfCelebs.Add(celeb); } } } catch (Exception ex) { Console.WriteLine(ex); } return(listOfCelebs); }
public List <Person> SortingNameAndGende(List <Person> persons, PersonGender gender) { switch (gender) { case PersonGender.male: var sortedPerson = from person in persons where person.gender == PersonGender.male orderby person.name select person; return(FillList(sortedPerson)); case PersonGender.female: sortedPerson = from person in persons where person.gender == PersonGender.female orderby person.name select person; return(FillList(sortedPerson)); default: return(new List <Person> { }); } }
// Add a new member of staff based on user entered data public bool AddStaff(int staffID, String firstName, String lastName, String addressLine1, String addressLine2, String city, String county, String postCode, DateTime dateOfBirth, String emailAddress, PersonGender gender, String maritalStatus, String telephoneNumber, PermissionsFlag permissions, String password) { // Create a new member of staff with all of their details Staff newStaff = new Staff(); newStaff.StaffID = staffID; newStaff.FirstName = EncodeMySql(firstName); newStaff.LastName = EncodeMySql(lastName); newStaff.AddressLine1 = EncodeMySql(addressLine1); newStaff.AddressLine2 = EncodeMySql(addressLine2); newStaff.City = EncodeMySql(city); newStaff.County = EncodeMySql(county); newStaff.PostCode = EncodeMySql(postCode); newStaff.DateOfBirth = dateOfBirth; newStaff.EmailAddress = EncodeMySql(emailAddress); newStaff.TelephoneNumber = EncodeMySql(telephoneNumber); newStaff.MaritalStatus = EncodeMySql(maritalStatus); newStaff.Gender = gender; newStaff.Permissions = permissions; SavePasswordFile(newStaff, password); return BusinessMetaLayer.AddStaffDetails(newStaff, GetSHAHash(password)); }
public Instructor(string Name, string LastName, int Age, PersonGender Gender, string ProfessionalSchedule) : base(Name, LastName, Age, Gender) { this.ProcessionalLicense = ProcessionalLicense; }
protected void ButtonSaveChanges_Click(object sender, EventArgs e) { // Check for dirty fields, one by one int currentUserId = Convert.ToInt32(HttpContext.Current.User.Identity.Name); Person currentUser = Person.FromIdentity(currentUserId); AuditedPerson aperson = AuditedPerson.FromPerson(Person, currentUser, "PersonBasicDetails"); if (this.TextName.Text != Person.Name) { if (!string.IsNullOrEmpty(aperson.PartyEmail)) { msgAskAboutPPAddress.Visible = true; //Show "alert" panel divMessage.InnerHtml = Server.HtmlEncode( this.GetLocalResourceObject("Interface.Controls.EditPerson.MsgAskForChangeMail").ToString()).Replace("[", "<").Replace("]", ">"); /*"[br/][br/] * [span style='font-size:1.1em;font-weight: bold']You changed your name.[/span][br/][br/] * Do you want yor party mail address @piratpartiet.se[br/] * to be changed as well?[br/] * [br/]"*/ } aperson.Name = this.TextName.Text; // causes a database op } if (this.TextStreet.Text != Person.Street) { aperson.Street = this.TextStreet.Text; // causes a database op } if (this.TextCity.Text != Person.CityName) { aperson.City = this.TextCity.Text; // causes two dbops } Cities cities = Cities.FromPostalCode(this.TextPostalCode.Text.Replace(" ", ""), this.DropCountries.SelectedValue); int personGeography = person.GeographyId; if (this.TextPostalCode.Text != Person.PostalCode) { aperson.PostalCode = this.TextPostalCode.Text; // causes two dbops } if (this.DropCountries.SelectedValue != Person.Country.Code) { aperson.Country = Country.FromCode(this.DropCountries.SelectedValue); // causes two dbops } Person tempPerson = Person.FromIdentity(this.Person.Identity); //important that this is after country, city and postcode, since they might resolve wrongly if (this.DropDownMunicipalities.SelectedValue != tempPerson.GeographyId.ToString()) { aperson.Geography = Geography.FromIdentity(int.Parse(this.DropDownMunicipalities.SelectedValue)); // causes two dbops } this.LabelEmailMessage.Text = ""; this.LabelEmailMessage.CssClass = ""; if (this.TextEmail.Text != Person.Email) { if (Formatting.ValidateEmailFormat(this.TextEmail.Text)) { aperson.Email = this.TextEmail.Text; // causes dbop if (aperson.MailUnreachable) { aperson.MailUnreachable = false; this.LabelEmailMessage.Text = string.Empty; } } else { this.TextEmail.CssClass = "DirtyInput"; this.LabelEmailMessage.Text = "Invalid Email Not Saved"; this.LabelEmailMessage.CssClass = "ErrorMessage"; this.TextEmail.Focus(); } } if (this.TextPhone.Text != Person.Phone) { string phone = Formatting.CleanNumber(this.TextPhone.Text); this.TextPhone.Text = phone; aperson.Phone = phone; // causes dbop } this.LabelBirthdateMessage.Text = ""; this.LabelBirthdateMessage.CssClass = ""; DateTime birthdate = DateTime.MinValue; if (DateTime.TryParse(this.TextBirthdate.Text, out birthdate)) { if (birthdate != Person.Birthdate) { aperson.Birthdate = birthdate; // causes dbop } this.TextBirthdate.CssClass = string.Empty; this.LabelBirthdateMessage.Text = string.Empty; } else { this.TextBirthdate.CssClass = "DirtyInput"; this.LabelBirthdateMessage.Text = "Invalid Date Not Saved"; this.LabelBirthdateMessage.CssClass = "ErrorMessage"; this.TextBirthdate.Focus(); } PersonGender gender = (PersonGender)Enum.Parse(typeof(PersonGender), this.DropGenders.SelectedValue); if (gender != Person.Gender) { aperson.Gender = gender; // causes dbop } string currentHandle = this.TextHandle.Text; try { currentHandle = Person.Handle; if (currentHandle == null) { currentHandle = string.Empty; } this.LabelHandleMessage.Text = string.Empty; this.TextHandle.CssClass = string.Empty; if (this.TextHandle.Text != currentHandle) { try { aperson.Handle = this.TextHandle.Text; } catch (HandleException exh) { this.TextHandle.CssClass = "DirtyInput"; if (exh.ErrorType == HandleErrorType.HandleNotFound) { this.LabelHandleMessage.Text = "Not Found"; } else if (exh.ErrorType == HandleErrorType.HandleOccupied) { this.LabelHandleMessage.Text = "Already in use, contact [email protected] if it is yours."; } else { this.LabelHandleMessage.Text = "Invalid Handle"; } this.LabelHandleMessage.CssClass = "ErrorMessage"; this.TextHandle.Focus(); } } } catch (Exception ex) { currentHandle = ""; this.TextHandle.Text = "Connection Error"; this.TextHandle.ToolTip = ex.Message; this.TextHandle.Enabled = false; } if (this.TextPersonalNumber.Text != Person.PersonalNumber) { aperson.PersonalNumber = this.TextPersonalNumber.Text; } this.LabelBankAccountMessage.CssClass = this.LabelBankNameMessage.CssClass = string.Empty; this.TextBankAccount.CssClass = this.TextBankName.CssClass = string.Empty; if (this.TextBankAccount.Text != Person.BankAccount || this.TextBankName.Text != Person.BankName || this.TextBankClearing.Text != Person.BankClearing) { // If we are saving the bank account, the name and account must either be both present // or both empty. if (this.TextBankName.Text.Trim() == string.Empty && this.TextBankAccount.Text.Trim() == string.Empty) { aperson.BankAccount = aperson.BankName = string.Empty; } else if (this.TextBankName.Text.Trim().Length > 1 && this.TextBankAccount.Text.Trim().Length > 4) { aperson.BankAccount = Formatting.CleanNumber(this.TextBankAccount.Text.Trim()); // causes dbops aperson.BankClearing = Formatting.CleanNumber(this.TextBankClearing.Text.Trim()); aperson.BankName = this.TextBankName.Text.Trim(); } else { // If we get here, only one of the fields have been set. this.TextBankName.CssClass = "DirtyInput"; this.TextBankAccount.CssClass = "DirtyInput"; this.LabelBankNameMessage.Text = "Must specify bank AND account"; this.LabelBankAccountMessage.Text = "Must specify bank AND account"; this.LabelBankNameMessage.CssClass = "ErrorMessage"; this.LabelBankAccountMessage.CssClass = "ErrorMessage"; if (this.TextBankAccount.Text.Trim().Length > 4) { this.TextBankName.Focus(); } else { this.TextBankAccount.Focus(); } } } if (this.TextPersonalNumber.Text != Person.PersonalNumber) { // TODO: Check for validity //aperson.PersonalNumber = this.TextPersonalNumber.Text.Trim(); } if (DataChanged != null) { DataChanged(this, new EventArgs()); } }
private Student CreateStudent(StudentType Type, string Name, PersonGender StudentGender, DateTime TimeStamp) { Student newStudent = new Student(Type, Name, StudentGender, TimeStamp); return(newStudent); }
private static double CalculateListMaleQuota (MeetingElectionCandidates candidates, PersonGender nextCandidateGender) { if (candidates.Count < 1) { return 0.5; // Division by zero protection, here and in caller } double malesTotal = 0.0; foreach (MeetingElectionCandidate candidate in candidates) { if (candidate.Person.Gender == PersonGender.Male) { malesTotal += 1.0; } } if (nextCandidateGender == PersonGender.Male) { malesTotal += 1.0; } return malesTotal/(candidates.Count + 1.0); }
private static int GetNextSpecificGenderCandidate (MeetingElectionCandidates candidates, Dictionary<int,bool> takenCandidates, PersonGender desiredGender) { int index = 0; while (takenCandidates.ContainsKey(index) || candidates [index].Person.Gender != desiredGender) { index++; // potential out-of-range exception here, if there aren't enough candidates } return index; }
public Student(string Name, string LastName, int Age, PersonGender Gender, string Schedule, decimal Score) : base(Name, LastName, Age, Gender) { this.Schedule = Schedule; this.Score = Score; }
public void SetPersonGender (int personId, PersonGender gender) { using (DbConnection connection = GetMySqlDbConnection()) { connection.Open(); DbCommand command = GetDbCommand("SetPersonGender", connection); command.CommandType = CommandType.StoredProcedure; AddParameterWithName(command, "personId", personId); AddParameterWithName(command, "genderId", (int)gender); command.ExecuteNonQuery(); } }
public int CreatePerson (string name, string email, string phone, string street, string postalCode, string city, int countryId, DateTime birthDate, PersonGender gender) { using (DbConnection connection = GetMySqlDbConnection()) { connection.Open(); DbCommand command = GetDbCommand("CreatePerson", connection); command.CommandType = CommandType.StoredProcedure; AddParameterWithName(command, "name", name); AddParameterWithName(command, "email", email); AddParameterWithName(command, "passwordHash", string.Empty); AddParameterWithName(command, "phoneNumber", phone); AddParameterWithName(command, "street", street); AddParameterWithName(command, "postalCode", postalCode); AddParameterWithName(command, "city", city); AddParameterWithName(command, "countryId", countryId); AddParameterWithName(command, "birthdate", birthDate); AddParameterWithName(command, "genderId", (int)gender); int personId = Convert.ToInt32(command.ExecuteScalar()); return personId; } }
public static Person Create (string name, string email, string password, string phone, string street, string postal, string city, string countryCode, DateTime dateOfBirth, PersonGender gender) { BasicCountry country = null; if (countryCode.Length > 0) { country = SwarmDb.GetDatabaseForReading().GetCountry(countryCode); } // Clean data while (name.Contains(" ")) { name = name.Replace(" ", " "); } name = name.Trim(); email = email.ToLower().Trim(); phone = LogicServices.CleanNumber(phone); postal = postal.Replace(" ", "").Trim(); int personId = SwarmDb.GetDatabaseForWriting().CreatePerson(name, email, phone, street, postal, city, country == null? 0: country.Identity, dateOfBirth, gender); // Resolve the geography Person newPerson = Person.FromIdentityAggressive(personId); // aggressive bypasses replication lag, avoids race condition newPerson.ResolveGeography(); // Generate the salted password hash and set it if (password.Length > 0) { newPerson.PasswordHash = Authentication.GenerateNewPasswordHash(personId, password); } else { newPerson.PasswordHash = string.Empty; // if no password, prevent matching to anything } // Return the finished Person object return newPerson; }