public ActionResult <PersonClass> Get(long id) { DataBaseManager manager = new DataBaseManager(); PersonClass person = manager.getPersonById(id); return(person); }
private static void ReferenceType()//copies reference only { var personC = new PersonClass { Age = 34, Name = "Khaloo Class" }; PersonClass personClass; personClass = personC;//refeernce is copied Console.WriteLine("Original Object: Before changing values"); Console.WriteLine($"{nameof(personC)} value is {personC}"); Console.WriteLine("Reference is copied: Before changing values"); Console.WriteLine($"{nameof(personClass)} value is {personClass}"); personClass.Age = 59; Console.WriteLine("Reference is copied: After changing values"); Console.WriteLine($"{nameof(personClass)} value is {personClass}"); Console.WriteLine("Original Object: After changing values"); Console.WriteLine($"{nameof(personC)} value is {personC}"); Console.ReadLine(); }
private void initializeBindings_SelectedIndexChanged(object sender, EventArgs e) { PersonClass selectedPerson = (PersonClass)initializeBindings.SelectedItem; //YearsExperiencePcicker.value = yearExperiencePicker.Value = selectedPerson.YearsExperience; }
//Delete person by id public bool deletePerson(long ID) { PersonClass person = new PersonClass(); SqlDataReader mySQLReader = null; try { String sqlQuery = "SELECT * FROM people WHERE ID = " + ID.ToString(); SqlCommand cmd = new SqlCommand(sqlQuery, conn); mySQLReader = cmd.ExecuteReader(); if (mySQLReader.Read()) { mySQLReader.Close(); sqlQuery = "DELETE FROM people WHERE ID = " + ID.ToString(); cmd = new SqlCommand(sqlQuery, conn); cmd.ExecuteNonQuery(); return(true); } else { return(false); } } catch (SqlException err) { throw err; } finally { conn.Close(); } }
public void CanCreateComProxy() { PersonClass person = new PersonClass(); person.Firstname = "Christian"; Assert.That(person.Firstname, Is.EqualTo("Christian")); }
private void Button_Click(object sender, RoutedEventArgs e) { if (txtNameFirst.Text != "" || txtNameMiddle.Text != "" || txtNameLast.Text != "") { bool exist = false; PersonClass GetName = new PersonClass(txtNameFirst.Text, txtNameLast.Text, txtNameMiddle.Text); foreach (string name in DataStorage.customerList) { if (name == GetName.GetFullName()) { MessageBox.Show("Error! Name already exists in database!"); exist = true; } } if (!exist) { DataStorage.customerList.Add(GetName.GetFullName()); int size = DataStorage.customerList.Count - 1; DataStorage.address.Insert(size, txtAddress.Text); DataStorage.contactNumber.Insert(size, txtContactNumber.Text); this.Close(); } } this.Close(); }
public Person(PersonClass personClass, string nome, int idade) { Id = -1; Class = personClass; Nome = nome; Idade = idade; }
//GET all persons public ArrayList getAllPersons() { ArrayList peopleArray = new ArrayList(); SqlDataReader mySQLReader = null; try { String sqlQuery = "SELECT * FROM people"; SqlCommand cmd = new SqlCommand(sqlQuery, conn); mySQLReader = cmd.ExecuteReader(); while (mySQLReader.Read()) { PersonClass person = new PersonClass { ID = mySQLReader.GetInt32(0), FirstName = mySQLReader.GetString(1), LastName = mySQLReader.GetString(2), Age = mySQLReader.GetInt32(3) }; peopleArray.Add(person); } return(peopleArray); } catch (SqlException err) { throw err; } finally { conn.Close(); } }
public Person(PersonClass personClass, string name, int age) { this.Id = -1; this.Class = personClass; this.Name = name; this.Age = age; }
private void DeleteButton_Click(object sender, RoutedEventArgs e) { PersonClass person = new PersonClass(); int id = Int32.Parse(idTextBox.Text); person.Delete(id); }
//GET person by ID public PersonClass getPersonById(long ID) { PersonClass person = new PersonClass(); SqlDataReader mySQLReader = null; try { String sqlQuery = "SELECT * FROM people WHERE ID = " + ID.ToString(); SqlCommand cmd = new SqlCommand(sqlQuery, conn); mySQLReader = cmd.ExecuteReader(); if (mySQLReader.Read()) { person.ID = mySQLReader.GetInt32(0); person.FirstName = mySQLReader.GetString(1); person.LastName = mySQLReader.GetString(2); person.Age = mySQLReader.GetInt32(3); return(person); } else { return(null); } } catch (SqlException err) { throw err; } finally { conn.Close(); } }
public void Demo() { PersonRecord personRecord1 = new(name, age); var personRecord2 = new PersonRecord(name, age); PersonClass personClass1 = new(name, age); var personClass2 = new PersonClass(name, age); Object.ReferenceEquals(personRecord1, personRecord2); WriteLine($"Test record equality -- personRecord1 == personRecord2 : {personRecord1 == personRecord2}"); WriteLine($"Test record equality -- personClass1 == personClass2 : {personClass1 == personClass2}"); WriteLine(); WriteLine($"Object.ReferenceEquals(personRecord1, personRecord2) : {Object.ReferenceEquals(personRecord1, personRecord2)}"); WriteLine($"Object.ReferenceEquals(personClass1, personClass2) : {Object.ReferenceEquals(personClass1, personClass2)}"); WriteLine(); WriteLine($"Print personRecord1 hash code -- personRecord1.GetHashCode(): {personRecord1.GetHashCode()}"); WriteLine($"Print personRecord2 hash code -- personRecord2.GetHashCode(): {personRecord2.GetHashCode()}"); WriteLine(); WriteLine($"Print personClass1 hash code -- personClass1.GetHashCode(): {personClass1.GetHashCode()}"); WriteLine($"Print personClass2 hash code -- personClass2.GetHashCode(): {personClass2.GetHashCode()}"); WriteLine(); WriteLine($"{nameof(PersonRecord)} implements IEquatable<T>: {personRecord1 is IEquatable<PersonRecord>} "); WriteLine($"{nameof(PersonClass)} implements IEquatable<T>: {personClass1 is IEquatable<PersonClass>}"); WriteLine(); WriteLine($"Print {nameof(PersonRecord)}.ToString -- personRecord1.ToString(): {personRecord1.ToString()}"); WriteLine($"Print {nameof(PersonClass)}.ToString -- personClass1.ToString(): {personClass1.ToString()}"); WriteLine(); }
public PersonCreatedEvent(int aggregateId, PersonClass personClass, string name, int age) { this.AggregateId = aggregateId; this.Class = personClass; this.Name = name; this.Age = age; }
private static List <string> naturalProficiencies(Race race, PersonClass personClass) { List <string> proficiencies = new List <string>(); proficiencies.AddRange(race.proficiencies); proficiencies.AddRange(personClass.classProficiencies); return(proficiencies); }
private void updatePersonButton_Click_Click(object sender, EventArgs e) { PersonClass selectedPerson = (PersonClass)initializeBindings.SelectedItem; selectedPerson.YearsExperience = Convert.ToInt32(yearExperiencePicker.Value); updateBindings(); }
private void RefreshButton_Click(object sender, RoutedEventArgs e) { DataTable dt = new DataTable(); PersonClass person = new PersonClass(); dt = person.Return(); podaciDataGrid.DataContext = dt.DefaultView; }
internal PersonClass(int age, int?id, string name, PersonClass peer, PersonClass[] peers) { Age = age; Id = id; Name = name; Peer = peer; Peers = peers; }
static void Main(string[] args) { string Ender; do { PersonClass Contact = new PersonClass(); while (Contact.First_Name == string.Empty) { Console.WriteLine("What is the Client's First Name?"); Contact.First_Name = Console.ReadLine().Trim(); } while (Contact.Last_Name == string.Empty) { Console.WriteLine("What is the Client's Last Name?"); Contact.Last_Name = Console.ReadLine().Trim(); } Console.WriteLine("If they have a middle name, enter it. Otherwise, just press [Enter]"); Contact.Middle_Name = Console.ReadLine().Trim(); Contact.Full_Name = new PersonClass().Full_Name_Maker(Contact); string AddressSelector= "x" ; while (AddressSelector != string.Empty) { Console.WriteLine("Is this address for the client's [H]ome, [W]ork, or [O]ther?"); Console.WriteLine(@"(To end editing addresses, just press [Enter])"); AddressSelector = Console.ReadKey().ToString().ToLower(); if (AddressSelector == "h") Contact.Address.AddressType = "HOME"; else if (AddressSelector == "w") Contact.Address.AddressType = "WORK"; else if (AddressSelector == string.Empty) continue; else { Console.WriteLine("What type of address is this?"); Contact.Address.AddressType = Console.ReadLine().ToUpper(); } Console.WriteLine("What is the client's street address?"); Contact.Address.AddressFirstLine = Console.ReadLine().ToUpper().Trim(); Console.WriteLine("If the address has a second line, enter it. Otherwise, just press [Enter]"); Contact.Address.AddressSecondLine = Console.ReadLine().ToUpper().Trim(); Console.WriteLine("What is the client's city?"); Contact.Address.City = Console.ReadLine().ToUpper().Trim(); while (Contact.Address.State.Length !=2) { Console.WriteLine("What is the client's state abbreviation?"); Contact.Address.State = Console.ReadLine(); } } new VCardMaker().SpitToFile(Contact); Console.WriteLine("Type exit to end. Press enter to create another VCard."); Ender = Console.ReadLine().Trim().ToLower(); } while (Ender != "exit"); }
// PRIVATES private static Dictionary <string, int> naturalSkills(Race race, PersonClass personClass, Culture culture) { Dictionary <string, int> skills = new Dictionary <string, int>(); skills = updateSkills(skills, race.skillBonuses); skills = updateSkills(skills, culture.skillBonuses); skills = updateSkills(skills, personClass.chooseRandomTrainedSkills()); return(skills); }
public Person(PersonClass personClass, string name, int age) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException("name"); } this.ApplyChange(new PersonCreatedEvent(0, personClass, name, age)); }
//POST new person public long savePerson(PersonClass personToSave) { String sqlQuery = "INSERT INTO people (FirstName, LastName, Age) VALUES ('" + personToSave.FirstName + "','" + personToSave.LastName + "'," + Convert.ToInt32(personToSave.Age) + ");" + "SELECT SCOPE_IDENTITY();"; SqlCommand cmd = new SqlCommand(sqlQuery, conn); decimal id = (decimal)cmd.ExecuteScalar(); return((long)id); }
public static Person newBorn(string name, string gender, Dictionary <string, Person> parents) { Race race = racialInheritance(parents); Culture culture = culturalInheritance(parents); Genes genes = geneticInheritance(parents); PersonClass personClass = randomClass(culture); List <string> proficiencies = naturalProficiencies(race, personClass); Dictionary <string, int> skills = naturalSkills(race, personClass, culture); return(new Person(name, gender, parents["father"].clan, parents["father"].name, parents["mother"].name, race, culture, personClass, genes, 1, proficiencies, skills)); }
public static Person newImmigrant(string name, string gender, string clan, Dictionary <string, Person> parents, Culture culture) { Race race = randomRace(culture); string father; string mother; if (parents.ContainsKey("father")) { father = parents["father"].name; } else { father = "unknown"; } if (parents.ContainsKey("mother")) { mother = parents["mother"].name; } else { mother = "unknown"; } PersonClass personClass = randomClass(culture); Genes genes; if (parents.Count == 2) { genes = geneticInheritance(parents); } else if (parents.Count == 1) { if (father == "unknown") { genes = new Genes(parents["mother"], culture); } else { genes = new Genes(parents["father"], culture); } } else { genes = new Genes(culture); } List <string> proficiencies = naturalProficiencies(race, personClass); Dictionary <string, int> skills = naturalSkills(race, personClass, culture); int age = race.randomAdultAge(); return(new Person(name, gender, clan, father, mother, race, culture, personClass, genes, age, proficiencies, skills)); }
public void Manual_Sort() { var length = Persons.Length; var copy = new PersonClass[length]; for (int i = 0; i < length; i++) { copy[i] = Persons[i]; } Array.Sort(copy, Manual_Comparer); }
public Person(int id, PersonClass personClass, string name, int idade) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException("name"); } this.Id = id; this.Class = personClass; this.Name = name; }
public HttpResponseMessage Post([FromBody] PersonClass value) { DataBaseManager manager = new DataBaseManager(); long id; id = manager.savePerson(value); value.ID = (int)id; HttpRequestMessage request = new HttpRequestMessage(); HttpResponseMessage response = request.CreateResponse(HttpStatusCode.Created); return(response); }
private void UpdateButton_Click(object sender, RoutedEventArgs e) { PersonClass person = new PersonClass(); person.FirstName = firstNameTextBox.Text; person.LastName = lastNameTextBox.Text; person.Age = Int32.Parse(ageTextBox.Text); person.Update(person); firstNameTextBox.Text = ""; lastNameTextBox.Text = ""; ageTextBox.Text = ""; }
private static PersonClass[] GetSourcePersons() { PersonClass p1 = new PersonClass("Mr", "Adam", 1), p2 = new PersonClass(null, "Ginger", 1), p3 = new PersonClass("Ms", "Lama", 1), p4 = new PersonClass("Dr", "Don", null), p5 = new PersonClass("Dr", "Zed", 42); PersonClass[] persons = new[] { p1, p2, p3, p4, p5 }; return(persons); }
public Person(int id, PersonClass personClass, string nome, int idade) { if (string.IsNullOrWhiteSpace(nome)) { throw new ArgumentNullException("nome"); } Id = id; Class = personClass; Nome = nome; Idade = idade; }
public Person(int id, PersonClass personClass, string name, int age) { if (String.IsNullOrWhiteSpace(name)) { throw new ArgumentException("Name is requerid"); } Id = id; Type = personClass; Name = name; Age = age; }
private void button1_Click(object sender, EventArgs e) { person = new PersonClass(txtUsername.Text, txtPassword.Text); if (person.LoginMethod()) { MessageBox.Show("user found."); } else { MessageBox.Show("F**k you. please try again. :)"); } }
public void SpitToFile(PersonClass person) { string FileName= string.Format("{2}{0}_{1}.vcf", person.Last_Name, person.First_Name, @"c:\temp\"); using (var fw = new StreamWriter(FileName)) { // write to the file fw.WriteLine("BEGIN:VCARD"); fw.WriteLine("VERSION:3.0"); fw.WriteLine(String.Format("N:{0};{1}", person.Last_Name, person.First_Name)); fw.WriteLine("FN:" + person.Full_Name); fw.WriteLine(String.Format("REV:{0}", System.DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ"))); fw.WriteLine("END:VCARD"); // close the stream fw.Close(); } }
internal PersonStruct(int age, int? id, string name, PersonClass peer, PersonClass[] peers) { Age = age; Id = id; Name = name; Peer = peer; Peers = peers; }
public PersonStruct(PersonClass[] peers) { Peers = peers; }
public PersonStruct(PersonClass peer) { Peer = peer; }
public PersonClass(PersonClass[] peers) { Peers = peers; }
public PersonClass(PersonClass peer) { Peer = peer; }
public string Full_Name_Maker(PersonClass person) { var first = person.First_Name; var middle = person.Middle_Name; var last = person.Last_Name; string full; if (middle == string.Empty) { full = String.Format("{0} {1}", first, last); } else full = String.Format("{0} {1} {2}", first, middle, last); return full; }