/// <summary> /// Update profile /// </summary> protected void btnSubmit_Click(object sender, EventArgs e) { using (var context = new PetShopDataContext()) { var options = new DataLoadOptions(); options.LoadWith<Profile>(p => p.AccountList); context.LoadOptions = options; var profile = context.Profile.GetProfile(User.Identity.Name); if (!string.IsNullOrEmpty(profile.Username) && AddressForm.IsValid) { if (profile.AccountList.Count > 0) { Account account = profile.AccountList[0]; UpdateAccount(ref account, AddressForm.Address); } else { var account = new Account(); profile.AccountList.Add(account); account.UniqueID = profile.UniqueID; UpdateAccount(ref account, AddressForm.Address); } context.SubmitChanges(); } } lblMessage.Text = "Your profile information has been successfully updated.<br> "; }
private void UpdateAccount(ref Account account, Address address) { account.FirstName = address.FirstName; account.LastName = address.LastName; account.Address1 = address.Address1; account.Address2 = address.Address2; account.City = address.City; account.State = address.State; account.Zip = address.Zip; account.Country = address.Country; account.Phone = address.Phone; account.Email = address.Email; }
private void OnAccountListRemove(Account entity) { SendPropertyChanging(null); entity.Profile = null; SendPropertyChanged(null); }
private void OnAccountListAdd(Account entity) { SendPropertyChanging(null); entity.Profile = this; SendPropertyChanged(null); }