Esempio n. 1
0
        /// <summary>
        /// Makes a clone (deep copy) of this object
        /// </summary>
        /// <returns>GeoCity object</returns>
        public GeoCity Clone()
        {
            GeoCity city = new GeoCity();

            city.Id             = Id;
            city.CityName       = CityName;
            city.CountryCodeISO = CountryCodeISO;
            city.Latitude       = Latitude;
            city.Longitude      = Longitude;
            city.Population     = Population;
            city.Elevation      = Elevation;

            city.IsNew      = IsNew;
            city.IsModified = IsModified;

            if (_imageCollection != null)
            {
                foreach (TravelImage image in _imageCollection)
                {
                    city.AddImage(image.Clone());
                }
            }

            return(city);
        }
Esempio n. 2
0
        /// <summary>
        /// Populates a TravelImage
        /// </summary>
        /// <param name="row"></param>
        public override void PopulateDataMembersFromDataRow(DataRow row)
        {
            // set the data members to the data retrieved from the database table/query

            if (row["ImageID"] == DBNull.Value)
            {
                Id = DEFAULT_ID;
            }
            else
            {
                Id = Convert.ToInt32(row["ImageID"]);
            }

            if (row["Path"] == DBNull.Value)
            {
                Path = "";
            }
            else
            {
                Path = Convert.ToString(row["Path"]);
            }

            if (row["UID"] != DBNull.Value)
            {
                _user           = new TravelUser();
                _user.Id        = Convert.ToInt32(row["UID"]);
                _user.FirstName = Convert.ToString(row["FirstName"]);
                _user.LastName  = Convert.ToString(row["LastName"]);
            }

            if (row["Title"] == DBNull.Value)
            {
                Title = "";
            }
            else
            {
                Title = Convert.ToString(row["Title"]);
            }

            if (row["Description"] == DBNull.Value)
            {
                Description = "";
            }
            else
            {
                Description = Convert.ToString(row["Description"]);
            }

            if (row["Latitude"] == DBNull.Value)
            {
                Latitude = 0.0;
            }
            else
            {
                Latitude = Convert.ToDouble(row["Latitude"]);
            }

            if (row["Longitude"] == DBNull.Value)
            {
                Longitude = 0.0;
            }
            else
            {
                Longitude = Convert.ToDouble(row["Longitude"]);
            }

            if (row["PostID"] != DBNull.Value)
            {
                _post       = new TravelPost();
                _post.Id    = Convert.ToInt32(row["PostID"]);
                _post.Title = Convert.ToString(row["PostTitle"]);
            }


            if (row["GeoNameID"] != DBNull.Value)
            {
                _city          = new GeoCity();
                _city.Id       = Convert.ToInt32(row["GeoNameID"]);
                _city.CityName = Convert.ToString(row["AsciiName"]);
            }

            if (row["ISO"] != DBNull.Value)
            {
                _country             = new GeoCountry();
                _country.Id          = Convert.ToString(row["ISO"]);
                _country.CountryName = Convert.ToString(row["CountryName"]);
            }

            if (row["RatingCount"] == DBNull.Value)
            {
                RatingCount = 0;
            }
            else
            {
                RatingCount = Convert.ToInt32(row["RatingCount"]);
            }

            if (row["RatingAverage"] == DBNull.Value)
            {
                RatingAverage = 0.0;
            }
            else
            {
                RatingAverage = Convert.ToDouble(row["RatingAverage"]);
            }

            // since we are populating this object from data set its object variables
            IsNew      = false;
            IsModified = false;
        }