public int SaveApplicant(string FirstName, string LastName, string DateOfBirth, string Region , string Active, string Address, string City, string Zip , string Phone, string Email, string Notes) { chsi.dat.acaApplicants applicant = new chsi.dat.acaApplicants(); applicant.FirstName = FirstName; applicant.LastName = LastName; applicant.isActive = (Active == "true")? true : false; applicant.Address = Address; applicant.City = City; applicant.Zip = Zip; applicant.Phone = Phone; applicant.Email = Email; applicant.DateOfBirth = Convert.ToDateTime(DateOfBirth); applicant.RegionId = Convert.ToInt32(Region); applicant.Notes = Notes; chsi.dat.CHSIEntities db = new chsi.dat.CHSIEntities(); db.acaApplicants.AddObject(applicant); db.SaveChanges(); return applicant.ApplicantId; }
protected void btnAddApplicant_Click(object sender, EventArgs e) { chsi.dat.CHSIEntities db = new chsi.dat.CHSIEntities(); int _appId = 0; if (!String.IsNullOrEmpty(Request.QueryString["appId"])) { string appId = Request.QueryString["appId"]; int.TryParse(appId, out _appId); } if (_appId == 0) { chsi.dat.acaApplicants app = new acaApplicants(); app.FirstName = this.txtFirstName.Text.Trim(); app.LastName = this.txtLastName.Text.Trim(); //app.Email = this.txtEmail.Text.Trim(); //app.Address = this.txtAddress.Text.Trim(); //app.City = this.txtCity.Text.Trim(); app.isPrimary = true; app.DateOfBirth = Convert.ToDateTime(this.txtDOB.Text); app.Phone = this.txtPhone.Text.Trim(); app.RegionId = int.Parse(this.ddRegion.SelectedValue); app.isActive = this.chkActive.Checked; //app.Zip = this.txtZip.Text.Trim(); app.Notes = this.txtNotes.Text.Trim(); db.acaApplicants.AddObject(app); db.SaveChanges(); int appId = app.ApplicantId; acaHealthPlans hp = new acaHealthPlans(); hp.ApplicantId = appId; db.acaHealthPlans.AddObject(hp); db.SaveChanges(); Response.Redirect(string.Format("/aca/assists?appId={0}", appId)); } else { acaApplicants app = (from a in db.acaApplicants where a.ApplicantId == _appId select a).FirstOrDefault(); app.FirstName = this.txtFirstName.Text.Trim(); app.LastName = this.txtLastName.Text.Trim(); //app.Email = this.txtEmail.Text.Trim(); //app.Address = this.txtAddress.Text.Trim(); //app.City = this.txtCity.Text.Trim(); app.DateOfBirth = Convert.ToDateTime(this.txtDOB.Text); app.isPrimary = true; app.Phone = this.txtPhone.Text.Trim(); app.RegionId = int.Parse(this.ddRegion.SelectedValue); app.isActive = this.chkActive.Checked; //app.Zip = this.txtZip.Text.Trim(); app.Notes = this.txtNotes.Text.Trim(); db.SaveChanges(); Response.Redirect(string.Format("/aca/assists?appId={0}", _appId)); } }
/// <summary> /// Deprecated Method for adding a new object to the acaApplicants EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToacaApplicants(acaApplicants acaApplicants) { base.AddObject("acaApplicants", acaApplicants); }
/// <summary> /// Create a new acaApplicants object. /// </summary> /// <param name="applicantId">Initial value of the ApplicantId property.</param> /// <param name="isPrimary">Initial value of the isPrimary property.</param> /// <param name="isActive">Initial value of the isActive property.</param> public static acaApplicants CreateacaApplicants(global::System.Int32 applicantId, global::System.Boolean isPrimary, global::System.Boolean isActive) { acaApplicants acaApplicants = new acaApplicants(); acaApplicants.ApplicantId = applicantId; acaApplicants.isPrimary = isPrimary; acaApplicants.isActive = isActive; return acaApplicants; }