Пример #1
0
        public string getAddressHTMLFormat()
        {
            string Address = Name + " " + LastName + "<br>";

            if (CompanyName == null || CompanyName.Equals("") || CompanyName.Equals(" "))
            {
                Address += "";
            }
            else
            {
                Address += CompanyName + "<br>";
            }
            Address += Address1 + "<br>";

            if (Address2 == null || Address2.Equals("") || Address2.Equals(" "))
            {
                Address += "";
            }
            else
            {
                Address += Address2 + "<br>";
            }

            Address += City + ", " + Stat + " " + Zip + "<br>"
                       + Country;

            return(Address);
        }
        public void Value_Object_Nullable_Guid_Property_Test()
        {
            var anAddress = new Address2(new Guid("21C67A65-ED5A-4512-AA29-66308FAAB5AF"), "Baris Manco Street", 42);
            var anotherAddress = new Address2(null, "Another street", 42);

            Assert.NotEqual(anAddress, anotherAddress);
            Assert.False(anotherAddress.Equals(anAddress));
            Assert.True(anAddress != anotherAddress);
        }
Пример #3
0
        public override bool Equals(object obj)
        {
            var otherAddress = obj as Address;

            if (otherAddress == null || Address1 == null)
            {
                return(false);
            }

            if (!Address1.Equals(otherAddress.Address1))
            {
                return(false);
            }
            if (Address2 != null)
            {
                if (!Address2.Equals(otherAddress.Address2))
                {
                    return(false);
                }
            }
            if (Suburb != null)
            {
                if (!Suburb.Equals(otherAddress.Suburb))
                {
                    return(false);
                }
            }
            if (Postcode != null)
            {
                if (!Postcode.Equals(otherAddress.Postcode))
                {
                    return(false);
                }
            }
            if (State != null)
            {
                if (!State.Equals(otherAddress.State))
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #4
0
        /* public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
         * {
         *   throw new NotImplementedException();
         * }
         */

        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            // validate 1 Addess2 cant be Address1
            if (Address2.Equals(Address1))
            {
                yield return(new ValidationResult("Address2 cannot be the same as Address1.", new[] { "Address" }));
            }

            // validate 2 State has to be 2 digits
            if (State.Length <= 1 && State.Length >= 3) // State >= 10 && State <=99
            {
                yield return(new ValidationResult("Enter a 2 digit State code.", new[] { "State" }));
            }

            // validate 3 Zipcode has to be 5 digits
            if (Zipcode.Length <= 4 && Zipcode.Length >= 6) // Zipcode >= 10000 && Zipcode <= 99999
            {
                yield return(new ValidationResult("Enter a 5 digit zipcode.", new[] { "Zipcode" }));
            }
        }
Пример #5
0
        IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            // validate 1 Addess2 cant be Address1
            if (Address2.Equals(Address1))
            {
                yield return(new ValidationResult("Address2 cannot be the same as Address1.", new[] { "Address" }));
            }

/*
 *          // validate 2 State has to be 2 digits
 *          if (State >= 10 && <=99)
 *          {
 *              yield return (new ValidationResult("Enter a 2 digit State code.", new[] { "State" }));
 *          }
 *
 *          // validate 3 Zipcode has to be 5 digits
 *          if (Zipcode >= 10000 && <= 99999)
 *          {
 *              yield return (new ValidationResult("Enter a 5 digit zipcode.", new[] { "Zipcode" }));
 *          }
 */
        }
Пример #6
0
        public override bool Encode(ref byte[] buffer)
        {
            /* First : determine the total number of characters	*/
            int NbBytes = count_nb_bytes();

            /* Second : create the whole byte array                         */
            int index = 0;
            int new_index;

            byte[] pl = new byte[NbBytes];

            new_index = AddLine(pl, pl.Length, index, "BEGIN:VCARD", "");
            if (new_index < 0)
            {
                Trace.WriteLine("Error generating 'VCard' object: after 'BEGIN'");
                return(false);
            }
            index = new_index;

            new_index = AddLine(pl, pl.Length, index, "VERSION:3.0", "");
            if (new_index < 0)
            {
                Trace.WriteLine("Error generating 'VCard' object: after 'VERSION'");
                return(false);
            }
            index = new_index;

            string name = _first_name + " " + _family_name;

            new_index = AddLine(pl, pl.Length, index, "FN:", name);
            if (new_index < 0)
            {
                Trace.WriteLine("Error generating 'VCard' object: after 'FN'");
                return(false);
            }
            index = new_index;


            if (!Nickname.Equals(""))
            {
                new_index = AddLine(pl, pl.Length, index, "NICKNAME:", Nickname);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'Nickname'");
                    return(false);
                }
                index = new_index;
            }

            DateTime dateBirthday;

            if ((!Birthday.Equals("")) && (DateTime.TryParse(Birthday, out dateBirthday)))
            {
                string Bday = convert_into_vcard_date(Birthday);
                new_index = AddLine(pl, pl.Length, index, "BDAY:", Bday);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'Birthday'");
                    return(false);
                }
                index = new_index;
            }

            if (!(Address1.Equals("")) ||
                !(Address2.Equals("")) ||
                !(Town.Equals("")) ||
                !(Region_State.Equals("")) ||
                !(Post_Code.Equals("")) ||
                !(Country.Equals(""))
                )
            {
                string addr_line = Address1 + ";" + Address2 + ";" + Town + ";"
                                   + Region_State + ";" + Post_Code + ";" + Country;
                new_index = AddLine(pl, pl.Length, index, "ADR:;", addr_line);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'Address'");
                    return(false);
                }
                index = new_index;
            }

            if (!(Pro_Address1.Equals("")) ||
                !(Pro_Address2.Equals("")) ||
                !(Pro_Town.Equals("")) ||
                !(Pro_Region_State.Equals("")) ||
                !(Pro_Post_Code.Equals("")) ||
                !(Pro_Country.Equals(""))
                )
            {
                string pro_addr_line = Pro_Address1 + ";" + Pro_Address2 + ";" + Pro_Town + ";"
                                       + Pro_Region_State + ";" + Pro_Post_Code + ";" + Pro_Country;
                new_index = AddLine(pl, pl.Length, index, "ADR;TYPE=work:;", pro_addr_line);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'Professional Address'");
                    return(false);
                }
                index = new_index;
            }

            if (!Home_phone.Equals(""))
            {
                new_index = AddLine(pl, pl.Length, index, "TEL;TYPE=home:", Home_phone);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'TEL;TYPE=home'");
                    return(false);
                }
                index = new_index;
            }


            if (!Business_phone.Equals(""))
            {
                new_index = AddLine(pl, pl.Length, index, "TEL;TYPE=work:", Business_phone);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'TEL;TYPE=work'");
                    return(false);
                }
                index = new_index;
            }

            if (!Cell_phone.Equals(""))
            {
                new_index = AddLine(pl, pl.Length, index, "TEL;TYPE=cell:", Cell_phone);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'TEL;TYPE=cell'");
                    return(false);
                }
                index = new_index;
            }

            if (!Pager.Equals(""))
            {
                new_index = AddLine(pl, pl.Length, index, "TEL;TYPE=pager:", Pager);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'TEL;TYPE=pager'");
                    return(false);
                }
                index = new_index;
            }

            if (!Fax.Equals(""))
            {
                new_index = AddLine(pl, pl.Length, index, "TEL;TYPE=fax:", Fax);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'TEL;TYPE=fax'");
                    return(false);
                }
                index = new_index;
            }

            if (!Email.Equals(""))
            {
                if (Email_alternative.Equals(""))
                {
                    new_index = AddLine(pl, pl.Length, index, "EMAIL:", Email);
                    if (new_index < 0)
                    {
                        Trace.WriteLine("Error generating 'VCard' object: after 'EMAIL'");
                        return(false);
                    }
                    index = new_index;
                }
                else
                {
                    /*	Two E-mails to add */
                    new_index = AddLine(pl, pl.Length, index, "EMAIL;PREF=1:", Email);
                    if (new_index < 0)
                    {
                        Trace.WriteLine("Error generating 'VCard' object: after 'EMAIL;PREF=1'");
                        return(false);
                    }
                    index = new_index;

                    new_index = AddLine(pl, pl.Length, index, "EMAIL;PREF=2:", Email_alternative);
                    if (new_index < 0)
                    {
                        Trace.WriteLine("Error generating 'VCard' object: after 'EMAIL;PREF=2'");
                        return(false);
                    }
                    index = new_index;
                }
            }

            if (!Title.Equals(""))
            {
                new_index = AddLine(pl, pl.Length, index, "TITLE:", Title);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'TITLE'");
                    return(false);
                }
                index = new_index;
            }

            if (!Role.Equals(""))
            {
                new_index = AddLine(pl, pl.Length, index, "ROLE:", Role);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'ROLE'");
                    return(false);
                }
                index = new_index;
            }

            if (!Company.Equals(""))
            {
                new_index = AddLine(pl, pl.Length, index, "ORG:", Company);
                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'ORG'");
                    return(false);
                }
                index = new_index;
            }

            if (!_photo.Equals(""))
            {
                new_index = AddLine(pl, pl.Length, index, "PHOTO;ENCODING=BASE64;TYPE=JPEG:", _photo);

                if (new_index < 0)
                {
                    Trace.WriteLine("Error generating 'VCard' object: after 'PHOTO'");
                    return(false);
                }

                index = new_index;
            }

            new_index = AddLine(pl, pl.Length, index, "END:VCARD", "");
            _payload  = pl;

            return(base.Encode(ref buffer));
        }
Пример #7
0
        private int count_nb_bytes()
        {
            /* All the ASCII strings in the VCard must be separated by 0x0D0A, which represent 2 characters */
            int NbBytes = 0;

            NbBytes  = "BEGIN:VCARD".Length + 2 + "VERSION:3.0".Length + 2;
            NbBytes += "FN:".Length + First_name.Length + 1 + Family_name.Length + 2;                           /* 1 is for "space"	*/

            if (!Nickname.Equals(""))
            {
                NbBytes += "NICKNAME:".Length + Nickname.Length + 2;
            }

            /* Birthday with 8 characters: yyyymmdd	*/
            DateTime dateBirthday;

            if ((!Birthday.Equals("")) && (DateTime.TryParse(Birthday, out dateBirthday)))
            {
                NbBytes += "BDAY:".Length + 8 + 2;
            }

            /* Home address in 6 fields, separated by a ';'						*/
            /* The PO Box is discarded, which explains the first ';'	*/
            if (!(Address1.Equals("")) ||
                !(Address2.Equals("")) ||
                !(Town.Equals("")) ||
                !(Region_State.Equals("")) ||
                !(Post_Code.Equals("")) ||
                !(Country.Equals(""))
                )
            {
                NbBytes += "ADR:;".Length
                           + Address1.Length + 1
                           + Address2.Length + 1
                           + Town.Length + 1
                           + Region_State.Length + 1
                           + Post_Code.Length + 1
                           + Country.Length + 2;
            }

            /* Work address in 6 fields, separated by a ';'						*/
            /* The PO Box is discarded, which explains the first ';'	*/
            if (!(Pro_Address1.Equals("")) ||
                !(Pro_Address2.Equals("")) ||
                !(Pro_Town.Equals("")) ||
                !(Pro_Region_State.Equals("")) ||
                !(Pro_Post_Code.Equals("")) ||
                !(Pro_Country.Equals(""))
                )
            {
                NbBytes += "ADR;TYPE=work:;".Length
                           + Pro_Address1.Length + 1
                           + Pro_Address2.Length + 1
                           + Pro_Town.Length + 1
                           + Pro_Region_State.Length + 1
                           + Pro_Post_Code.Length + 1
                           + Pro_Country.Length + 2;
            }

            if (!Home_phone.Equals(""))
            {
                NbBytes += "TEL;TYPE=home:".Length + Home_phone.Length + 2;
            }

            if (!Business_phone.Equals(""))
            {
                NbBytes += "TEL;TYPE=work:".Length + Business_phone.Length + 2;
            }

            if (!Cell_phone.Equals(""))
            {
                NbBytes += "TEL;TYPE=cell:".Length + Cell_phone.Length + 2;
            }

            if (!Fax.Equals(""))
            {
                NbBytes += "TEL;TYPE=fax:".Length + Fax.Length + 2;
            }

            if (!Pager.Equals(""))
            {
                NbBytes += "TEL;TYPE=pager:".Length + Pager.Length + 2;
            }

            if (!Email.Equals(""))
            {
                if (Email_alternative.Equals(""))
                {
                    NbBytes += "EMAIL:".Length + Email.Length + 2;
                }
                else
                {
                    /* TWO EMAILS : PREF=1 and PREF=2	*/
                    NbBytes += "EMAIL;PREF=1:".Length + Email.Length + 2 + "EMAIL;PREF=2:".Length + Email_alternative.Length + 2;
                }
            }

            if (!Title.Equals(""))
            {
                NbBytes += "TITLE:".Length + Title.Length + 2;
            }

            if (!Role.Equals(""))
            {
                NbBytes += "ROLE:".Length + Role.Length + 2;
            }

            if (!Company.Equals(""))
            {
                NbBytes += "ORG:".Length + Company.Length + 2;
            }

            if (!_photo.Equals(""))
            {
                NbBytes += "PHOTO;ENCODING=BASE64;TYPE=JPEG:".Length + _photo.Length + 2;
            }

            NbBytes += "END:VCARD".Length + 2;

            return(NbBytes);
        }
Пример #8
0
        /// <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)
                 ));
        }
Пример #9
0
        /// <summary>
        /// Returns true if Address instances are equal
        /// </summary>
        /// <param name="other">Instance of Address to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Address other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     ReferenceNumber == other.ReferenceNumber ||
                     ReferenceNumber != null &&
                     ReferenceNumber.Equals(other.ReferenceNumber)
                     ) &&
                 (
                     FirstName == other.FirstName ||
                     FirstName != null &&
                     FirstName.Equals(other.FirstName)
                 ) &&
                 (
                     LastName == other.LastName ||
                     LastName != null &&
                     LastName.Equals(other.LastName)
                 ) &&
                 (
                     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)
                 ) &&
                 (
                     State == other.State ||
                     State != null &&
                     State.Equals(other.State)
                 ) &&
                 (
                     CountryCode == other.CountryCode ||
                     CountryCode != null &&
                     CountryCode.Equals(other.CountryCode)
                 ) &&
                 (
                     PostalCode == other.PostalCode ||
                     PostalCode != null &&
                     PostalCode.Equals(other.PostalCode)
                 ) &&
                 (
                     PhoneNumber == other.PhoneNumber ||
                     PhoneNumber != null &&
                     PhoneNumber.Equals(other.PhoneNumber)
                 ));
        }
Пример #10
0
        /// <summary>
        /// Returns true if Owner instances are equal
        /// </summary>
        /// <param name="other">Instance of Owner to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Owner other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id.Equals(other.Id)
                     ) &&
                 (
                     OwnerCode == other.OwnerCode ||
                     OwnerCode != null &&
                     OwnerCode.Equals(other.OwnerCode)
                 ) &&
                 (
                     OrganizationName == other.OrganizationName ||
                     OrganizationName != null &&
                     OrganizationName.Equals(other.OrganizationName)
                 ) &&
                 (
                     MeetsResidency == other.MeetsResidency ||
                     MeetsResidency.Equals(other.MeetsResidency)
                 ) &&
                 (
                     LocalArea == other.LocalArea ||
                     LocalArea != null &&
                     LocalArea.Equals(other.LocalArea)
                 ) &&
                 (
                     Status == other.Status ||
                     Status != null &&
                     Status.Equals(other.Status)
                 ) &&
                 (
                     StatusComment == other.StatusComment ||
                     StatusComment != null &&
                     StatusComment.Equals(other.StatusComment)
                 ) &&
                 (
                     DoingBusinessAs == other.DoingBusinessAs ||
                     DoingBusinessAs != null &&
                     DoingBusinessAs.Equals(other.DoingBusinessAs)
                 ) &&
                 (
                     RegisteredCompanyNumber == other.RegisteredCompanyNumber ||
                     RegisteredCompanyNumber != null &&
                     RegisteredCompanyNumber.Equals(other.RegisteredCompanyNumber)
                 ) &&
                 (
                     PrimaryContact == other.PrimaryContact ||
                     PrimaryContact != null &&
                     PrimaryContact.Equals(other.PrimaryContact)
                 ) &&
                 (
                     IsMaintenanceContractor == other.IsMaintenanceContractor ||
                     IsMaintenanceContractor != null &&
                     IsMaintenanceContractor.Equals(other.IsMaintenanceContractor)
                 ) &&
                 (
                     WorkSafeBCPolicyNumber == other.WorkSafeBCPolicyNumber ||
                     WorkSafeBCPolicyNumber != null &&
                     WorkSafeBCPolicyNumber.Equals(other.WorkSafeBCPolicyNumber)
                 ) &&
                 (
                     WorkSafeBCExpiryDate == other.WorkSafeBCExpiryDate ||
                     WorkSafeBCExpiryDate != null &&
                     WorkSafeBCExpiryDate.Equals(other.WorkSafeBCExpiryDate)
                 ) &&
                 (
                     GivenName == other.GivenName ||
                     GivenName != null &&
                     GivenName.Equals(other.GivenName)
                 ) &&
                 (
                     Surname == other.Surname ||
                     Surname != null &&
                     Surname.Equals(other.Surname)
                 ) &&
                 (
                     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)
                 ) &&
                 (
                     CGLEndDate == other.CGLEndDate ||
                     CGLEndDate != null &&
                     CGLEndDate.Equals(other.CGLEndDate)
                 ) &&
                 (
                     CglPolicyNumber == other.CglPolicyNumber ||
                     CglPolicyNumber != null &&
                     CglPolicyNumber.Equals(other.CglPolicyNumber)
                 ) &&
                 (
                     ArchiveCode == other.ArchiveCode ||
                     ArchiveCode != null &&
                     ArchiveCode.Equals(other.ArchiveCode)
                 ) &&
                 (
                     ArchiveReason == other.ArchiveReason ||
                     ArchiveReason != null &&
                     ArchiveReason.Equals(other.ArchiveReason)
                 ) &&
                 (
                     ArchiveDate == other.ArchiveDate ||
                     ArchiveDate != null &&
                     ArchiveDate.Equals(other.ArchiveDate)
                 ) &&
                 (
                     Contacts == other.Contacts ||
                     Contacts != null &&
                     Contacts.SequenceEqual(other.Contacts)
                 ) &&
                 (
                     Notes == other.Notes ||
                     Notes != null &&
                     Notes.SequenceEqual(other.Notes)
                 ) &&
                 (
                     Attachments == other.Attachments ||
                     Attachments != null &&
                     Attachments.SequenceEqual(other.Attachments)
                 ) &&
                 (
                     History == other.History ||
                     History != null &&
                     History.SequenceEqual(other.History)
                 ) &&
                 (
                     EquipmentList == other.EquipmentList ||
                     EquipmentList != null &&
                     EquipmentList.SequenceEqual(other.EquipmentList)
                 ));
        }