Пример #1
0
        /// <summary>
        /// Populates a TravelImageRating
        /// </summary>
        /// <param name="row">a row</param>
        public override void PopulateDataMembersFromDataRow(DataRow row)
        {
            // set the data members to the data retrieved from the database table/query
            if (row["ImageRatingID"] == DBNull.Value)
            {
                Id = DEFAULT_ID;
            }
            else
            {
                Id = Convert.ToInt32(row["ImageRatingID"]);
            }

            if (row["ImageID"] != DBNull.Value)
            {
                _image    = new TravelImage();
                _image.Id = Convert.ToInt32(row["ImageID"]);
            }

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

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

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

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

            // since we are populating this object from data set its object variables
            IsNew      = false;
            IsModified = false;
        }
Пример #2
0
        /// <summary>
        /// Makes a clone (deep copy) of this object
        /// </summary>
        public TravelImage Clone()
        {
            TravelImage image = new TravelImage();

            image.Id            = Id;
            image.Path          = Path;
            image.Title         = Title;
            image.Description   = Description;
            image.Latitude      = Latitude;
            image.Longitude     = Longitude;
            image.RatingCount   = RatingCount;
            image.RatingAverage = RatingAverage;

            image.IsNew      = IsNew;
            image.IsModified = IsModified;

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

            if (_city != null)
            {
                image._city = _city.Clone();
            }

            if (_country != null)
            {
                image._country = _country.Clone();
            }

            if (_post != null)
            {
                image._post = _post.Clone();
            }

            return(image);
        }
Пример #3
0
        /// <summary>
        /// Checks to see if 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);
            }

            TravelImage image = (TravelImage)obj;

            if (this.Id != image.Id)
            {
                return(false);
            }
            return(true);
        }
Пример #4
0
 /// <summary>
 /// Adds a image to _imageCollection field
 /// </summary>
 /// <param name="image">a image</param>
 public void AddImage(TravelImage image)
 {
     ImageCollection.Add(image);
 }
Пример #5
0
 /// <summary>
 /// Adds a image to _imageCollection field
 /// </summary>
 /// <param name="image">a image</param>
 private void AddImage(TravelImage image)
 {
     _imageCollection.Add(image);
 }