/// <summary> /// Populates a TravelPost /// </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["PostID"] == DBNull.Value) { Id = DEFAULT_ID; } else { Id = Convert.ToInt32(row["PostID"]); } 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["Message"] == DBNull.Value) { Message = ""; } else { Message = Convert.ToString(row["Message"]); } if (row["PostTime"] == DBNull.Value) { PostTime = ""; } else { PostTime = Convert.ToString(row["PostTime"]); } // since we are populating this object from data set its object variables IsNew = false; IsModified = false; }
/// <summary> /// Makes a clone (deep copy) of this object /// </summary> public TravelUser Clone() { TravelUser user = new TravelUser(); user.Id = Id; user.UserName = UserName; user.FirstName = FirstName; user.LastName = LastName; user.Address = _address; user.City = City; user.Region = Region; user.Country = Country; user.Postal = _postal; user.Phone = _phone; user.Email = Email; user.Privacy = Privacy; user.IsNew = IsNew; user.IsModified = IsModified; user._showPersonalData = _showPersonalData; if (_imageCollection != null) { foreach (TravelImage image in _imageCollection) { user.AddImage(image.Clone()); } } if (_postCollection != null) { foreach (TravelPost post in _postCollection) { user.AddPost(post.Clone()); } } return(user); }
/// <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; }