Exemplo n.º 1
0
        /// <summary>
        /// Makes a clone (deep copy) of this object
        /// </summary>
        /// <returns>TravelPost Object</returns>
        public TravelPost Clone()
        {
            TravelPost post = new TravelPost();

            post.Id       = Id;
            post.Title    = Title;
            post.Message  = Message;
            post.PostTime = PostTime;

            post.IsNew      = IsNew;
            post.IsModified = IsModified;

            if (_user != null)
            {
                post._user = _user.Clone();
            }

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

            return(post);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Checks to see if an this object is equal to this object
        /// </summary>
        /// <param name="obj">a obj</param>
        /// <returns>true/false value</returns>
        public override bool Equals(Object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            if (this.GetType() != obj.GetType())
            {
                return(false);
            }

            TravelPost post = (TravelPost)obj;

            if (this.Id != post.Id)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Adds a post to _postCollection field
 /// </summary>
 /// <param name="image">a post</param>
 private void AddPost(TravelPost post)
 {
     _postCollection.Add(post);
 }