protected void SaveButton_Click(object sender, EventArgs e) { var container = new DeliveryManagerModelContainer(); User user; var userIDParam = Request.QueryString[UserConstants.IDParamName]; if (userIDParam != null) { int userID = Int32.Parse(userIDParam); user = container.Users.Single(u => u.Id == userID); } else { if (Page is AddEditClientPage) user = new Client(); else user = new Courier(); container.Users.AddObject(user); } user.FullName = ParseName(NameTextBox.Text.Trim()); user.Phone = PhoneTextBox.Text.Trim(); user.Email = EmailTextBox.Text.Trim(); container.SaveChanges(); Response.Redirect("~/Users/UsersList.aspx", true); }
/// <summary> /// Create a new Client object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="phone">Initial value of the Phone property.</param> /// <param name="fullName">Initial value of the FullName property.</param> public static Client CreateClient(global::System.Int32 id, global::System.String phone, FullName fullName) { Client client = new Client(); client.Id = id; client.Phone = phone; client.FullName = StructuralObject.VerifyComplexObjectIsNotNull(fullName, "FullName"); return client; }