protected void Page_Load(object sender, EventArgs e)
        {
            var childId = Request.QueryString["ChildId"];
            var albumId = Request.QueryString["AlbumId"];
            if (!string.IsNullOrEmpty(albumId))
                _album = LoadAlbum(long.Parse(albumId));

            if (_album != null)
                Create.Text = "Save";

            if (_album != null && !IsPostBack)
            {
                AlbumTitle.Text = _album.Title;
                AlbumDescription.Text = _album.Description;
            }
            _child = LoadChild(long.Parse(childId));
        }
 /// <summary>
 /// Create a new Child object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="firstName">Initial value of the FirstName property.</param>
 /// <param name="lastName">Initial value of the LastName property.</param>
 /// <param name="dateOfBirth">Initial value of the DateOfBirth property.</param>
 /// <param name="last4SSN">Initial value of the Last4SSN property.</param>
 public static Child CreateChild(global::System.Int64 id, global::System.String firstName, global::System.String lastName, global::System.DateTime dateOfBirth, global::System.String last4SSN)
 {
     Child child = new Child();
     child.Id = id;
     child.FirstName = firstName;
     child.LastName = lastName;
     child.DateOfBirth = dateOfBirth;
     child.Last4SSN = last4SSN;
     return child;
 }
        public void On_Save_Click(object sender, EventArgs e)
        {
            var child = new Child()
            {
                FirstName = txtFirstName.Text,
                LastName = txtLastName.Text,
                DateOfBirth = DateTime.Parse(txtDateOfBirth.Text),
                City = txtCity.Text,
                State = txtState.Text,
                Country = txtCountry.Text,
                BirthWeight = txtBirthWeight.Text,
                BirthLength = txtBirthWeight.Text,
                Last4SSN = txtLast4SSN.Text,
            };

            if (ProfileUser != null)
            {
                //Wire up database to save child

                Child childuser = new Child();
                childuser.FirstName = child.FirstName;
                childuser.LastName = child.LastName;
                childuser.DateOfBirth = child.DateOfBirth;
                childuser.City = child.City;
                childuser.State = child.State;
                childuser.Country = child.Country;
                childuser.BirthWeight = child.BirthWeight;
                childuser.BirthLength = child.BirthLength;
                childuser.Last4SSN = child.Last4SSN;
                childuser.Users.Add(ProfileUser);
                childuser.Albums.Add(new Album()
                {
                    Title = "Important Documents",
                    IsImportanDocumentsAlbum = true
                });

                childuser.Albums.Add(new Album()
                {
                    Title = "ProfilePicture",
                    IsProfilePictureAlbum = true
                });
                DataContext.AddToChildren(childuser);
                DataContext.SaveChanges();
            }

            string redirectLocation = "ChildCreatedConfirmation.aspx?ChildId=" + child.Id;
            if (ProfileUser != null)
                redirectLocation = redirectLocation + "&UserId=" + _userId;

            var childId = Request.QueryString["ChildId"];
            var userId = Request.QueryString["UserId"];

            var confirmationMessageBuilder = new StringBuilder().AppendFormat("A new child {0} was created", child.FirstName + " " + child.LastName);

            if (ProfileUser != null)
                confirmationMessageBuilder.AppendFormat(" and associated with the user {0}", ProfileUser.LoginName);

            NewForm.Visible = false;
            ConfirmationDialog.Visible = true;
            ConfirmationMessage.Text = confirmationMessageBuilder.ToString();
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Children EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToChildren(Child child)
 {
     base.AddObject("Children", child);
 }
 private void UpdateConfirmationMessageWithInformationAboutUpdatedChild(Child updatedChild)
 {
     ConfirmationDialog.Visible = true;
     ConfirmationMessage.Text = string.Format("User {0} was added as an authorized user for {1} {2}", ProfileUser.LoginName, updatedChild.FirstName, updatedChild.LastName);
     EditForm.Visible = false;
 }