using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AUDIOTEKA
{
    public partial class EditUser : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (User.Identity.IsAuthenticated)
                {
                    Email.Text = Membership.FindUsersByName(User.Identity.Name)[User.Identity.Name].Email;
                }
            }
        }
        protected void DeleteAccount_click(object sender, EventArgs e)
        {

            MembershipUser myUser = Membership.GetUser();
            string UserToDelete = myUser.UserName;

            if (UserToDelete == User.Identity.Name)
            {
                FormsAuthentication.SignOut();
            }
            Membership.DeleteUser(UserToDelete);
        }

        protected void SubmitNewMail_Click(object sender, EventArgs e)
        {
            if (User.Identity.IsAuthenticated)
            {
                MembershipUser CurrentUser = Membership.FindUsersByName(User.Identity.Name)[User.Identity.Name];

                CurrentUser.Email = Email.Text;

                Membership.UpdateUser(CurrentUser);
                //DeleteLabel.Visible = true;
            }
        }
    }
}
