// PRG: Need to check on parameter to be passed
        public UserPreferences GetUserPreferences(int userId)
        {
            DataSet ds = new DataSet();
            UserPreferences userPref = new UserPreferences();

            try
            {
                Database db = DatabaseFactory.CreateDatabase();

                string sqlCommand = "usp_GetUserPreference";
                DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

                db.AddInParameter(dbCommand, "PersonID", DbType.Int32, userId);

                ds = db.ExecuteDataSet(dbCommand);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = ds.Tables[0].Rows[0];

                    if (true == System.Convert.ToBoolean(ConfigUtil.GetConfigItem("EnableHideAddressFunctionality")))
                    {
                        userPref.Address = dr["Address"].ToString();
                    }
                    else
                    {
                        userPref.Address = "Y";
                    }

                    userPref.AwardsHonors = dr["AwardsHonors"].ToString();
                    if (true == System.Convert.ToBoolean(ConfigUtil.GetConfigItem("EnableHideEmailFunctionality")))
                    {
                        userPref.Email = dr["Email"].ToString();
                    }
                    else
                    {
                        userPref.Email = "Y";
                    }
                    userPref.Narrative = dr["Narrative"].ToString();
                    userPref.Photo = dr["Photo"].ToString();
                    userPref.Publications = dr["Publications"].ToString();
                    userPref.PhotoPref = Int32.Parse((dr["PhotoPreference"].ToString()));
                    userPref.ProfileExists = true;
                }
            }
            catch
            {
                userPref.ProfileExists = false;
            }

            return userPref;
        }
示例#2
0
        public string GetUserPhotoURL(int personId)
        {
            UserPreferences userPreference = new UserPreferences();
            userPreference = new UserBL().GetUserPreferences(personId);

            string url = ConfigUtil.GetConfigItem("DefaultPersonImageURL");

            if (userPreference.PhotoPref == 9)
            {
                url = string.Format("Thumbnail.ashx?id={0}&random={1}", personId, new Random().Next().ToString());
            }
            else
            {
                DataSet photoDS = new PhotoDA().GetUserPhotoList(personId, 2);

                if (photoDS.Tables[0].Rows.Count > 0)
                {
                    if (photoDS.Tables[0].Rows[userPreference.PhotoPref] != null)
                        url = Convert.ToString(photoDS.Tables[0].Rows[userPreference.PhotoPref]["PhotoLink"]);
                }
            }

            return url;
        }