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 Courier 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 Courier CreateCourier(global::System.Int32 id, global::System.String phone, FullName fullName) { Courier courier = new Courier(); courier.Id = id; courier.Phone = phone; courier.FullName = StructuralObject.VerifyComplexObjectIsNotNull(fullName, "FullName"); return courier; }