Esempio n. 1
0
        public static UserProfileBO getUserProfile(Guid id_passed)
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DB_CST465"].ConnectionString);

            SqlCommand command = new SqlCommand();

            command.Connection  = connection;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "UserProfile_Get";
            UserProfileBO ret_user = new UserProfileBO();

            command.Parameters.Add(new SqlParameter("@UserId", id_passed));
            try
            {
                connection.Open();

                SqlDataReader reader = command.ExecuteReader();

                if (reader.Read())
                {
                    ret_user.UserID        = (Guid)reader[0];
                    ret_user.firstName     = (string)reader[1];
                    ret_user.lastName      = (string)reader[2];
                    ret_user.age           = reader[3].ToString();
                    ret_user.phoneNumber   = (string)reader[4];
                    ret_user.emailAddress  = (string)reader[5];
                    ret_user.streetAddress = (string)reader[6];
                    ret_user.city          = (string)reader[7];
                    ret_user.state         = (string)reader[8];
                    ret_user.zipCode       = (string)reader[9];

                    if (reader[10] != System.DBNull.Value)
                    {
                        ret_user.profileImage = (byte[])reader[10];
                    }
                    else
                    {
                        ret_user.profileImage = null;
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                connection.Close();
            }



            return(ret_user);
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session != null)// && Session["ProfileData"] != null)
            {
                uxMultiView.ActiveViewIndex = 1;

                //userBusinessObject = Session["ProfileData"] as UserProfileBO;

                MembershipUser user   = Membership.GetUser();
                Guid           userID = (Guid)user.ProviderUserKey;

                userBusinessObject = UserProfileRepo.getUserProfile(userID);

                v2FirstName.Text     = userBusinessObject.firstName;
                v2Lastname.Text      = userBusinessObject.lastName;
                v2Age.Text           = userBusinessObject.age;
                v2PhoneNumber.Text   = userBusinessObject.phoneNumber;
                v2Email.Text         = userBusinessObject.emailAddress;
                v2StreetAddress.Text = userBusinessObject.streetAddress;
                v2City.Text          = userBusinessObject.city;
                v2State.Text         = userBusinessObject.state;
                v2ZipCode.Text       = userBusinessObject.zipCode;
                string base64StringBO = "";
                using (MemoryStream m = new MemoryStream(userBusinessObject.profileImage))
                {
                    byte[] imageBytes = m.ToArray();
                    // Convert byte[] to Base64 String
                    base64StringBO = Convert.ToBase64String(imageBytes);
                }
                if (!string.IsNullOrEmpty(base64StringBO))
                {
                    base64StringBO = "data:image/jpeg;base64," + base64StringBO;
                }

                uxImage.ImageUrl = base64StringBO;
            }
        }
Esempio n. 3
0
        protected void v1SaveButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                userBusinessObject = new UserProfileBO();

                MembershipUser user   = Membership.GetUser();
                Guid           userID = (Guid)user.ProviderUserKey;

                userBusinessObject.UserID = userID;

                userBusinessObject.firstName           = v1FirstName.Text;
                userBusinessObject.lastName            = v1LastName.Text;
                userBusinessObject.age                 = v1Age.Text;
                userBusinessObject.phoneNumber         = v1PhoneNumber.Text;
                userBusinessObject.emailAddress        = v1Email.Text;
                userBusinessObject.reenterEmailAddress = v1EmailCompare.Text;
                userBusinessObject.streetAddress       = v1StreetAddress.Text;
                userBusinessObject.city                = v1City.Text;
                userBusinessObject.state               = v1State.Text;
                userBusinessObject.zipCode             = v1ZipCode.Text;

                if (v1ProfileImage.HasFile)
                {
                    byte[] buffer = new byte[v1ProfileImage.PostedFile.ContentLength];
                    v1ProfileImage.PostedFile.InputStream.Read(buffer, 0, v1ProfileImage.PostedFile.ContentLength);
                    userBusinessObject.profileImage = buffer;
                }


                UserProfileRepo.saveUserProfile(userBusinessObject);
                //Session["ProfileData"] = userBusinessObject;
                uxMultiView.ActiveViewIndex = 1;
                Response.Redirect("UserProfile.aspx");
            }
        }
Esempio n. 4
0
        public static void saveUserProfile(UserProfileBO user)
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DB_CST465"].ConnectionString);

            SqlCommand command = new SqlCommand();

            command.Connection  = connection;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "UserProfile_InsertUpdate";

            command.Parameters.Add(new SqlParameter("@UserId", user.UserID));
            command.Parameters.Add(new SqlParameter("@FirstName", user.firstName));
            command.Parameters.Add(new SqlParameter("@LastName", user.lastName));
            command.Parameters.Add(new SqlParameter("@Age", user.age));
            command.Parameters.Add(new SqlParameter("@PhoneNumber", user.phoneNumber));
            command.Parameters.Add(new SqlParameter("@EmailAddress", user.emailAddress));
            command.Parameters.Add(new SqlParameter("@StreetAddress", user.streetAddress));
            command.Parameters.Add(new SqlParameter("@City", user.city));
            command.Parameters.Add(new SqlParameter("@State", user.state));
            command.Parameters.Add(new SqlParameter("@ZipCode", user.zipCode));
            command.Parameters.Add(new SqlParameter("@ProfileImage", user.profileImage));

            try
            {
                connection.Open();
                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                connection.Close();
            }
        }