using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace ApplicationServicesDemo
{
    public partial class ProfileMaintenance : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                UserProfile userProfile = UserProfile.GetUserProfile();
                TextBoxFavoriteColor.Text = userProfile.FavoriteColor;
                TextBoxPetsName.Text = userProfile.PetsName;
                TextBoxNews.Text = userProfile.HomePageSettings.News;
                TextBoxWeather.Text = userProfile.HomePageSettings.Weather;
                TextBoxSports.Text = userProfile.HomePageSettings.Sports;
            }
        }

        protected void ButtonSaveClick(object sender, EventArgs e)
        {
            UserProfile userProfile = UserProfile.GetUserProfile();
            userProfile.FavoriteColor = TextBoxFavoriteColor.Text;
            userProfile.PetsName = TextBoxPetsName.Text;
            userProfile.HomePageSettings.News = TextBoxNews.Text;
            userProfile.HomePageSettings.Weather = TextBoxWeather.Text;
            userProfile.HomePageSettings.Sports = TextBoxSports.Text;
            userProfile.Save();
        }
    }
}
