Exemplo n.º 1
0
        public void Constructor()
        {
            WebPerson person;

            person = new WebPerson();
            Assert.IsNotNull(person);
        }
 public WebPerson GetPerson(Boolean refresh)
 {
     if (_person.IsNull() || refresh)
     {
         _person = ArtDatabanken.WebService.UserService.Data.UserManager.GetPerson(GetContext(), Settings.Default.TestPersonId);
     }
     return(_person);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Check the data in current object
 /// </summary>
 /// <param name='person'>The person.</param>
 public static void CheckData(this WebPerson person)
 {
     if (!person.IsDataChecked)
     {
         person.CheckStrings();
         person.IsDataChecked = true;
     }
 }
Exemplo n.º 4
0
 private WebPerson GetPerson(Boolean refresh)
 {
     if (_person.IsNull() || refresh)
     {
         _person = new WebPerson();
     }
     return(_person);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Load data into the WebPerson instance.
 /// </summary>
 /// <param name='person'>The person.</param>
 /// <param name='dataReader'>An open data reader.</param>
 public static void LoadData(this WebPerson person,
                             DataReader dataReader)
 {
     person.Id                   = dataReader.GetInt32(PersonData.ID);
     person.GUID                 = dataReader.GetString(PersonData.GUID);
     person.FirstName            = dataReader.GetString(PersonData.FIRST_NAME);
     person.MiddleName           = dataReader.GetString(PersonData.MIDDLE_NAME);
     person.LastName             = dataReader.GetString(PersonData.LAST_NAME);
     person.GenderId             = dataReader.GetInt32(PersonData.GENDER_ID);
     person.EmailAddress         = dataReader.GetString(EmailData.EMAIL_ADDRESS);
     person.ShowEmailAddress     = dataReader.GetBoolean(EmailData.SHOW_EMAIL, false);
     person.ShowAddresses        = dataReader.GetBoolean(PersonData.SHOW_ADDRESSES);
     person.ShowPhoneNumbers     = dataReader.GetBoolean(PersonData.SHOW_PHONENUMBERS);
     person.LocaleISOCode        = dataReader.GetString(LocaleData.LOCALE_STRING);
     person.TaxonNameTypeId      = dataReader.GetInt32(PersonData.TAXON_NAME_TYPE_ID);
     person.IsBirthYearSpecified = dataReader.IsNotDbNull(PersonData.BIRTH_YEAR);
     if (person.IsBirthYearSpecified)
     {
         person.BirthYear = dataReader.GetDateTime(PersonData.BIRTH_YEAR);
     }
     person.IsDeathYearSpecified = dataReader.IsNotDbNull(PersonData.DEATH_YEAR);
     if (person.IsDeathYearSpecified)
     {
         person.DeathYear = dataReader.GetDateTime(PersonData.DEATH_YEAR);
     }
     person.IsUserIdSpecified = dataReader.IsNotDbNull(PersonData.USER_ID);
     if (person.IsUserIdSpecified)
     {
         person.UserId = dataReader.GetInt32(PersonData.USER_ID);
     }
     person.URL                             = dataReader.GetString(PersonData.URL);
     person.Presentation                    = dataReader.GetString(PersonData.PRESENTATION);
     person.ShowPresentation                = dataReader.GetBoolean(PersonData.SHOW_PRESENTATION);
     person.ShowPersonalInformation         = dataReader.GetBoolean(PersonData.SHOW_PERSONALINFORMATION);
     person.IsAdministrationRoleIdSpecified = dataReader.IsNotDbNull(PersonData.ADMINISTRATION_ROLE_ID);
     if (person.IsAdministrationRoleIdSpecified)
     {
         person.AdministrationRoleId = dataReader.GetInt32(PersonData.ADMINISTRATION_ROLE_ID);
     }
     person.HasSpeciesCollection = dataReader.GetBoolean(PersonData.HAS_COLLECTION);
     person.CreatedDate          = dataReader.GetDateTime(PersonData.CREATED_DATE);
     person.CreatedBy            = dataReader.GetInt32(PersonData.CREATED_BY, 0);
     person.ModifiedDate         = dataReader.GetDateTime(PersonData.MODIFIED_DATE);
     person.ModifiedBy           = dataReader.GetInt32(PersonData.MODIFIED_BY, 0);
 }
        public void LoadData()
        {
            WebPerson person;

            using (DataReader dataReader = GetContext().GetUserDatabase().GetPerson(Settings.Default.TestPersonId, Settings.Default.SwedenLocaleId))
            {
                person = new WebPerson();
                Assert.IsTrue(dataReader.Read());
                person.LoadData(dataReader);
                Assert.AreEqual(Settings.Default.TestPersonId, person.Id);
                Assert.AreEqual(Settings.Default.TestEmailAddress, person.EmailAddress);
                Assert.AreEqual(0, person.TaxonNameTypeId);
                Assert.AreEqual(0, person.AdministrationRoleId);
                Assert.IsTrue(person.IsUserIdSpecified);
                Assert.AreEqual(Settings.Default.TestUserId, person.UserId);
                Assert.IsTrue(person.ShowPersonalInformation);
                Assert.IsFalse(person.IsDeathYearSpecified);
                Assert.IsTrue(person.IsBirthYearSpecified);
            }
        }
 /// <summary>
 /// Get full name of person.
 /// </summary>
 /// <param name='person'>Person.</param>
 /// <returns>A version of text that is safe to use.</returns>
 public static String GetFullName(this WebPerson person)
 {
     return(person.FirstName + " " + person.LastName);
 }
 public WebPersonExtensionTest()
 {
     _person = null;
 }
Exemplo n.º 9
0
        /// <summary>
        /// Get table with information about new species facts to create.
        /// </summary>
        /// <param name="context">Web service request context.</param>
        /// <param name="speciesFacts">New species facts to create.</param>
        /// <param name="now">Create date and time for the new species facts.</param>
        /// <param name="fullName">The Full name of the editor. Optional.</param>
        /// <returns>Table with species fact information.</returns>
        public static DataTable GetSpeciesFactCreateTable(WebServiceContext context,
                                                          List <WebSpeciesFact> speciesFacts,
                                                          DateTime now,
                                                          String fullName)
        {
            DataTable speciesFactTable = GetSpeciesFactTable();

            if (speciesFacts.IsNotEmpty())
            {
                int       nextSpeciesFactId = context.GetTaxonAttributeDatabase().GetMaxSpeciesFactId() + 1;
                DataRow   row;
                WebPerson person = null;

                if (fullName.IsEmpty())
                {
                    person = WebServiceData.UserManager.GetPerson(context);
                }

                foreach (WebSpeciesFact speciesFact in speciesFacts)
                {
                    row    = speciesFactTable.NewRow();
                    row[0] = nextSpeciesFactId++;
                    row[1] = speciesFact.FactorId;
                    row[2] = speciesFact.TaxonId;
                    row[3] = speciesFact.IsPeriodSpecified
                                            ? (speciesFact.PeriodId == 3 ? 0 : speciesFact.PeriodId + 18)
                                            : speciesFact.IndividualCategoryId;
                    row[4] = speciesFact.ReferenceId;
                    row[5] = 0;
                    row[6] = now.Date;
                    // ReSharper disable once PossibleNullReferenceException
                    row[7] = person.IsNotNull() ? person.FirstName + " " + person.LastName : fullName;
                    if (speciesFact.IsFieldValue1Specified)
                    {
                        row[8] = speciesFact.FieldValue1;
                    }

                    if (speciesFact.IsFieldValue2Specified)
                    {
                        row[9] = speciesFact.FieldValue2;
                    }

                    if (speciesFact.IsFieldValue3Specified)
                    {
                        row[10] = speciesFact.FieldValue3;
                    }

                    if (speciesFact.IsFieldValue4Specified)
                    {
                        row[11] = speciesFact.FieldValue4;
                    }

                    if (speciesFact.IsFieldValue5Specified)
                    {
                        row[12] = speciesFact.FieldValue5;
                    }

                    row[13] = speciesFact.IsHostSpecified ? speciesFact.HostId : 0;
                    row[14] = speciesFact.QualityId;
                    if (speciesFact.IsPeriodSpecified)
                    {
                        row[15] = speciesFact.PeriodId;
                    }

                    row[16] = speciesFact.IndividualCategoryId;
                    speciesFactTable.Rows.Add(row);
                }
            }

            return(speciesFactTable);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Get table with information about new species facts to update.
        /// </summary>
        /// <param name="context">Web service request context.</param>
        /// <param name="speciesFacts">Species facts to update.</param>
        /// <returns>Table with species fact information.</returns>
        public static DataTable GetSpeciesFactUpdateTable(WebServiceContext context,
                                                          List <WebSpeciesFact> speciesFacts)
        {
            DataTable speciesFactTable = GetSpeciesFactUpdateTable();

            if (speciesFacts.IsNotEmpty())
            {
                DataRow   row;
                WebPerson person   = WebServiceData.UserManager.GetPerson(context);
                String    fullName = person.IsNotNull() ? person.FirstName + " " + person.LastName : String.Empty;

                foreach (WebSpeciesFact speciesFact in speciesFacts)
                {
                    row    = speciesFactTable.NewRow();
                    row[0] = speciesFact.Id;
                    row[1] = speciesFact.ReferenceId;
                    row[2] = fullName;
                    if (speciesFact.IsFieldValue1Specified)
                    {
                        row[3] = speciesFact.FieldValue1;
                    }
                    else
                    {
                        row[3] = DBNull.Value;
                    }

                    if (speciesFact.IsFieldValue2Specified)
                    {
                        row[4] = speciesFact.FieldValue2;
                    }
                    else
                    {
                        row[4] = DBNull.Value;
                    }

                    if (speciesFact.IsFieldValue3Specified)
                    {
                        row[5] = speciesFact.FieldValue3;
                    }
                    else
                    {
                        row[5] = DBNull.Value;
                    }

                    if (speciesFact.IsFieldValue4Specified)
                    {
                        row[6] = speciesFact.FieldValue4;
                    }
                    else
                    {
                        row[6] = DBNull.Value;
                    }

                    if (speciesFact.IsFieldValue5Specified)
                    {
                        row[7] = speciesFact.FieldValue5;
                    }
                    else
                    {
                        row[7] = DBNull.Value;
                    }

                    row[8] = speciesFact.QualityId;
                    speciesFactTable.Rows.Add(row);
                }
            }

            return(speciesFactTable);
        }
Exemplo n.º 11
0
 public WebPersonTest()
 {
     _person = null;
 }