public RegisterOutput Execute( FirstName firstName, LastName lastName, Personnummer personnummer, Email email, MobilePhoneNumber mobilePhoneNumber) {
public void Cleanup() { DC = null; DM = null; DS = null; person = null; location = null; stationaryNumber = null; mobileNumber = null; contact = null; }
public void Startup() { DC = new DataContext(server, database); DM = new DataManagement(DC); DS = new DataService(DM); location = new Location(city, zipCode); person = new Person(name, surname, location); stationaryNumber = new StationaryPhoneNumber(sNumber); mobileNumber = new MobilePhoneNumber(mNumber); contact = new Contact(person, mobileNumber); }
static void Main(string[] args) { string server = ".\\SQLEXPRESS"; string database = "PhoneBook"; DataManagement DM = new DataManagement(new DataContext(server, database)); Location l = new Location("Lodz", "00-000"); Location l2 = new Location("Lodz", "10-000"); Location l3 = new Location("Lodz", "20-000"); Person p = new Person("Tomasz", "Smolarek", l); Person p2 = new Person("Learn", "C#", l2); Person p3 = new Person("Love", "It", l3); PhoneNumber n = new MobilePhoneNumber("607890726"); PhoneNumber n2 = new MobilePhoneNumber("607890726"); PhoneNumber n3 = new MobilePhoneNumber(); Contact c = new Contact(p, n); Contact c2 = new Contact(p2, n2); Contact c3 = new Contact(p3, n3); DM.Insert(c); DM.Insert(c2); DM.Insert(c3); Console.WriteLine(DM.DoesExistContact(c)); System.Threading.Thread.Sleep(5000); DM.Remove(c); DM.Remove(c2); DM.Remove(c3); Console.WriteLine(DM.DoesExistContact(c)); Console.WriteLine(n3.Number); int count = DM.CountRows("Contacts"); Console.WriteLine(count); }
/// <summary> /// Creates a new <see cref="CommunicationWay" /> instance from the provided model. /// </summary> /// <param name="model">The model coming from the API.</param> /// <returns>Returns the created communication way instance.</returns> private CommunicationWay GetCommunicationWay(Models.CommunicationWays.CommunicationWay model) { // Initializes the communication way CommunicationWay communicationWay; // Creates the appriopriate instance switch (model.type) { case "PHONE": communicationWay = new PhoneNumber(); break; case "MOBILE": communicationWay = new MobilePhoneNumber(); break; case "WEB": communicationWay = new Website(); break; case "EMAIL": default: communicationWay = new EmailAddress(); break; } // Sets the communication way specific properties communicationWay.Id = model.id; communicationWay.CreationDateTime = DateTime.Parse(model.create); communicationWay.UpdateDateTime = DateTime.Parse(model.update); communicationWay.IsPrimary = model.main != "0"; communicationWay.Value = model.value; communicationWay.Kind = model.key == null ? null : this.GetCommunicationWayKind(model.key); // Returns the created communication way return(communicationWay); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { int hash = 41; // Suitable nullity checks hash = hash * 59 + Id.GetHashCode(); if (GivenName != null) { hash = hash * 59 + GivenName.GetHashCode(); } if (Surname != null) { hash = hash * 59 + Surname.GetHashCode(); } if (OrganizationName != null) { hash = hash * 59 + OrganizationName.GetHashCode(); } if (Role != null) { hash = hash * 59 + Role.GetHashCode(); } if (Notes != null) { hash = hash * 59 + Notes.GetHashCode(); } if (EmailAddress != null) { hash = hash * 59 + EmailAddress.GetHashCode(); } if (WorkPhoneNumber != null) { hash = hash * 59 + WorkPhoneNumber.GetHashCode(); } if (MobilePhoneNumber != null) { hash = hash * 59 + MobilePhoneNumber.GetHashCode(); } if (FaxPhoneNumber != null) { hash = hash * 59 + FaxPhoneNumber.GetHashCode(); } if (Address1 != null) { hash = hash * 59 + Address1.GetHashCode(); } if (Address2 != null) { hash = hash * 59 + Address2.GetHashCode(); } if (City != null) { hash = hash * 59 + City.GetHashCode(); } if (Province != null) { hash = hash * 59 + Province.GetHashCode(); } if (PostalCode != null) { hash = hash * 59 + PostalCode.GetHashCode(); } return(hash); } }
/// <summary> /// Returns true if Contact instances are equal /// </summary> /// <param name="other">Instance of Contact to be compared</param> /// <returns>Boolean</returns> public bool Equals(Contact other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id.Equals(other.Id) ) && ( GivenName == other.GivenName || GivenName != null && GivenName.Equals(other.GivenName) ) && ( Surname == other.Surname || Surname != null && Surname.Equals(other.Surname) ) && ( OrganizationName == other.OrganizationName || OrganizationName != null && OrganizationName.Equals(other.OrganizationName) ) && ( Role == other.Role || Role != null && Role.Equals(other.Role) ) && ( Notes == other.Notes || Notes != null && Notes.Equals(other.Notes) ) && ( EmailAddress == other.EmailAddress || EmailAddress != null && EmailAddress.Equals(other.EmailAddress) ) && ( WorkPhoneNumber == other.WorkPhoneNumber || WorkPhoneNumber != null && WorkPhoneNumber.Equals(other.WorkPhoneNumber) ) && ( MobilePhoneNumber == other.MobilePhoneNumber || MobilePhoneNumber != null && MobilePhoneNumber.Equals(other.MobilePhoneNumber) ) && ( FaxPhoneNumber == other.FaxPhoneNumber || FaxPhoneNumber != null && FaxPhoneNumber.Equals(other.FaxPhoneNumber) ) && ( Address1 == other.Address1 || Address1 != null && Address1.Equals(other.Address1) ) && ( Address2 == other.Address2 || Address2 != null && Address2.Equals(other.Address2) ) && ( City == other.City || City != null && City.Equals(other.City) ) && ( Province == other.Province || Province != null && Province.Equals(other.Province) ) && ( PostalCode == other.PostalCode || PostalCode != null && PostalCode.Equals(other.PostalCode) )); }
public override int GetHashCode() { int hash = 1; if (entityId_ != null) { hash ^= EntityId.GetHashCode(); } if (FirstName.Length != 0) { hash ^= FirstName.GetHashCode(); } if (LastName.Length != 0) { hash ^= LastName.GetHashCode(); } if (HomeAddress1.Length != 0) { hash ^= HomeAddress1.GetHashCode(); } if (HomeAddress2.Length != 0) { hash ^= HomeAddress2.GetHashCode(); } if (HomeCity.Length != 0) { hash ^= HomeCity.GetHashCode(); } if (HomeState.Length != 0) { hash ^= HomeState.GetHashCode(); } if (HomeZip.Length != 0) { hash ^= HomeZip.GetHashCode(); } if (HomeNation.Length != 0) { hash ^= HomeNation.GetHashCode(); } if (HomePhoneNumber.Length != 0) { hash ^= HomePhoneNumber.GetHashCode(); } if (OfficeAddress1.Length != 0) { hash ^= OfficeAddress1.GetHashCode(); } if (OfficeAddress2.Length != 0) { hash ^= OfficeAddress2.GetHashCode(); } if (OfficeCity.Length != 0) { hash ^= OfficeCity.GetHashCode(); } if (OfficeState.Length != 0) { hash ^= OfficeState.GetHashCode(); } if (OfficeZip.Length != 0) { hash ^= OfficeZip.GetHashCode(); } if (OfficeNation.Length != 0) { hash ^= OfficeNation.GetHashCode(); } if (OfficePhoneNumber.Length != 0) { hash ^= OfficePhoneNumber.GetHashCode(); } if (MobilePhoneNumber.Length != 0) { hash ^= MobilePhoneNumber.GetHashCode(); } if (FaxNumber.Length != 0) { hash ^= FaxNumber.GetHashCode(); } if (EmailAddress.Length != 0) { hash ^= EmailAddress.GetHashCode(); } if (IsBlacklisted != false) { hash ^= IsBlacklisted.GetHashCode(); } if (CompanyName.Length != 0) { hash ^= CompanyName.GetHashCode(); } if (GivenName2.Length != 0) { hash ^= GivenName2.GetHashCode(); } return(hash); }