コード例 #1
0
ファイル: UsersController.cs プロジェクト: Koelion/XOXO
        public void AddAvatar([FromBody] UserCover userCover)
        {
            var user = userRepositoryService.Get(userCover.UserID);

            user.ProvileAvatar = userCover.AvatarUrl;
            userRepositoryService.Update(user);
            unitOfWork.Save();
        }
コード例 #2
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        FileUpload     fup         = UserCover.FindControl("FileUpload2") as FileUpload;
        MembershipUser currentUser = Membership.GetUser();

        if (currentUser != null)
        {
            Guid currentUserId = (Guid)currentUser.ProviderUserKey;

            //if (txtNewPost.Text != string.Empty)
            //{
            string connectionString =
                ConfigurationManager.ConnectionStrings["SecurityConnectionString"].ConnectionString;
            string updateSql = "UPDATE UserProfiles SET CoverPicture = @CoverPicture WHERE UserId = @UserId";

            using (SqlConnection myConnection = new SqlConnection(connectionString))
            {
                myConnection.Open();
                SqlCommand myCommand = new SqlCommand(updateSql, myConnection);
                myCommand.Parameters.AddWithValue("@UserId", currentUserId);
                if (fup.HasFile)
                {
                    HttpPostedFile file = fup.PostedFile;

                    byte[] data = new byte[file.ContentLength];

                    file.InputStream.Read(data, 0, file.ContentLength);
                    myCommand.Parameters.AddWithValue("@CoverPicture", data);
                }

                myCommand.ExecuteNonQuery();
                myConnection.Close();
            }

            // }
        }
        //    Session["result"] = "Complete";
        //}

        Response.Redirect("~/index.aspx");
    }