예제 #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="p"></param>
        /// <param name="editedBy"></param>
        /// <returns></returns>
        public static bool UpdateUserProfile(UserProfile p, string editedBy = "")
        {
            bool success = false;

            using (var dbConn = new OdbcConnection(PostgreSQLConnectionString))
            {
                using (var dbCommand = dbConn.CreateCommand())
                {
                    dbCommand.CommandText = UpdateUserProfile_QUERY;

                    dbCommand.Parameters.AddWithValue("@FirstName", p.FirstName);
                    dbCommand.Parameters.AddWithValue("@LastName", p.LastName);
                    dbCommand.Parameters.AddWithValue("@Email", p.Email);
                    dbCommand.Parameters.AddWithValue("@WebsiteURL", p.WebsiteURL);
                    dbCommand.Parameters.AddWithValue("@SponsorName", p.SponsorName);

                    if (p.SponsorLogo != null)
                    {
                        dbCommand.Parameters.AddWithValue("@SponsorLogo", p.SponsorLogo);
                    }
                    else
                    {

                        dbCommand.Parameters.AddWithValue("@SponsorLogo", DBNull.Value);

                    }

                    if (!string.IsNullOrEmpty(p.SponsorLogoContentType))
                    {
                        dbCommand.Parameters.AddWithValue("@SponsorLogoContentType", p.SponsorLogoContentType);
                    }
                    else
                    {

                        dbCommand.Parameters.AddWithValue("@SponsorLogoContentType", DBNull.Value);
                    }

                    dbCommand.Parameters.AddWithValue("@DeveloperName", p.DeveloperName);

                    if (p.DeveloperLogo != null)
                    {
                        dbCommand.Parameters.AddWithValue("@DeveloperLogo", p.DeveloperLogo);
                    }
                    else
                    {
                        dbCommand.Parameters.AddWithValue("@DeveloperLogo", DBNull.Value);
                    }

                    if (!string.IsNullOrEmpty(p.DeveloperLogoContentType))
                    {
                        dbCommand.Parameters.AddWithValue("@DeveloperLogoContentType", p.DeveloperLogoContentType);
                    }
                    else
                    {
                        dbCommand.Parameters.AddWithValue("@DeveloperLogoContentType", DBNull.Value);

                    }

                    dbCommand.Parameters.AddWithValue("@ArtistName", p.ArtistName);
                    dbCommand.Parameters.AddWithValue("@Phone", p.Phone);

                    dbCommand.Parameters.AddWithValue("@LastEditedBy", editedBy);
                    dbCommand.Parameters.AddWithValue("@LastEditedDate", DateTime.Now.Date);

                    if (!string.IsNullOrEmpty(p.DeveloperLogoFileName))
                    {
                        dbCommand.Parameters.AddWithValue("@DeveloperLogoFileName", p.DeveloperLogoFileName);
                    }
                    else
                    {

                        dbCommand.Parameters.AddWithValue("@DeveloperLogoFileName", DBNull.Value);
                    }

                    if (!string.IsNullOrEmpty(p.SponsorLogoFileName))
                    {
                        dbCommand.Parameters.AddWithValue("@SponsorLogoFileName", p.SponsorLogoFileName);
                    }
                    else
                    {

                        dbCommand.Parameters.AddWithValue("@SponsorLogoFileName", DBNull.Value);
                    }

                    dbCommand.Parameters.AddWithValue("@UserID", p.UserID);

                    try
                    {
                        dbConn.Open();

                        int rowsAffected = -1;

                        //update
                        rowsAffected = dbCommand.ExecuteNonQuery();

                        if (rowsAffected > -1)
                        {
                            success = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        string error = ex.InnerException.ToString();
                    }
                }
            }
            return success;
        }
예제 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        private static UserProfile GetUserProfileFromDataTable(DataTable dt)
        {
            UserProfile rv = null;

            if (dt != null && dt.Rows.Count > 0)
            {
                rv = new UserProfile();

                DataRow row = dt.Rows[0];

                rv.InternalUserID = Int32.Parse(row["UserID"].ToString());
                rv.InternalMembershipUserGuid = row["UserGuid"].ToString();

                if (row["FirstName"] != DBNull.Value)
                {
                    rv.FirstName = row["FirstName"].ToString();
                }

                if (row["LastName"] != DBNull.Value)
                {
                    rv.LastName = row["LastName"].ToString();
                }

                if (row["Email"] != DBNull.Value)
                {
                    rv.Email = row["Email"].ToString();
                }

                if (row["WebsiteURL"] != DBNull.Value)
                {
                    rv.WebsiteURL = row["WebsiteURL"].ToString();
                }

                if (row["SponsorName"] != DBNull.Value)
                {
                    rv.SponsorName = row["SponsorName"].ToString();
                }

                if (row["SponsorLogo"] != DBNull.Value)
                {
                    rv.SponsorLogo = (byte[])row["SponsorLogo"];
                }

                if (row["SponsorLogoContentType"] != DBNull.Value)
                {
                    rv.SponsorLogoContentType = row["SponsorLogoContentType"].ToString();
                }

                if (row["SponsorLogoFileName"] != DBNull.Value)
                {
                    rv.SponsorLogoFileName = row["SponsorLogoFileName"].ToString();
                }

                if (row["DeveloperName"] != DBNull.Value)
                {
                    rv.DeveloperName = row["DeveloperName"].ToString();
                }

                if (row["DeveloperLogo"] != DBNull.Value)
                {
                    rv.DeveloperLogo = (byte[])row["DeveloperLogo"];
                }

                if (row["DeveloperLogoContentType"] != DBNull.Value)
                {
                    rv.DeveloperLogoContentType = row["DeveloperLogoContentType"].ToString();
                }

                if (row["DeveloperLogoFileName"] != DBNull.Value)
                {
                    rv.DeveloperLogoFileName = row["DeveloperLogoFileName"].ToString();
                }

                if (row["ArtistName"] != DBNull.Value)
                {
                    rv.ArtistName = row["ArtistName"].ToString();
                }

                if (row["Phone"] != DBNull.Value)
                {
                    rv.Phone = row["Phone"].ToString();
                }

                if (row["UserName"] != DBNull.Value)
                {
                    rv.UserName = row["UserName"].ToString();
                }
            }
            return rv;
        }