protected void wdgContacts_ItemCommand(object sender, Infragistics.Web.UI.GridControls.HandleCommandEventArgs e) { ClaimContact claimContact = null; int contactID = 0; int claimID = SessionHelper.getClaimID(); if (e.CommandName == "DoImport") { try { contactID = Convert.ToInt32(e.CommandArgument); claimContact = new ClaimContact(); claimContact.ClaimID = claimID; claimContact.ContactID = contactID; ClaimContactManager.Save(claimContact); lblImportContactMessage.Text = "Contact was imported successfully."; lblImportContactMessage.CssClass = "ok"; } catch (Exception ex) { Core.EmailHelper.emailError(ex); lblImportContactMessage.Text = "Contact was not imported."; lblImportContactMessage.CssClass = "error"; } } }
public static ClaimContact Save(ClaimContact contact) { DbContextHelper.DbContext.Add(contact); DbContextHelper.DbContext.SaveChanges(); return(contact); }
public static void Delete(int id) { // Create an entity to represent the Entity you wish to delete // Notice you don't need to know all the properties, in this // case just the ID will do. ClaimContact claimContact = new ClaimContact { ClaimContactID = id }; // Now attach the category stub object to the "Categories" set. // This puts the Entity into the context in the unchanged state, // This is same state it would have had if you made the query DbContextHelper.DbContext.AttachTo("ClaimContacts", claimContact); // Do the delete the category DbContextHelper.DbContext.DeleteObject(claimContact); // Apply the delete to the database DbContextHelper.DbContext.SaveChanges(); }
protected void wdgContacts_ItemCommand(object sender, Infragistics.Web.UI.GridControls.HandleCommandEventArgs e) { ClaimContact claimContact = null; int contactID = 0; int claimID = SessionHelper.getClaimID(); if (e.CommandName == "DoImport") { try { contactID = Convert.ToInt32(e.CommandArgument); claimContact = new ClaimContact(); claimContact.ClaimID = claimID; claimContact.ContactID = contactID; ClaimContactManager.Save(claimContact); lblImportContactMessage.Text = "Contact was imported successfully."; lblImportContactMessage.CssClass = "ok"; } catch (Exception ex) { Core.EmailHelper.emailError(ex); lblImportContactMessage.Text = "Contact was not imported."; lblImportContactMessage.CssClass = "error"; } } }
protected void saveContact() { bool isNewContact = false; int contactID = Convert.ToInt32(ViewState["ContactID"]); Contact contact = null; ClaimContact claimContact = null; lblMessage.Text = string.Empty; if (contactID == 0) { // new contact contact = new Contact(); contact.ClientID = Core.SessionHelper.getClientId(); isNewContact = true; } else contact = ContactManager.Get(contactID); contact.FirstName = txtFirstName.Text; contact.LastName = txtLastName.Text; contact.ContactName = txtFirstName.Text + " " + txtLastName.Text; contact.Phone = txtContactPhone.Text; contact.Email = txtContactEmail.Text; contact.Phone = txtContactPhone.Text; contact.Mobile = txtMobilePhone.Text; contact.ContactTitle = txtContactTile.Text; contact.DepartmentName = txtDepartmentName.Text; contact.IsPrimary = cbxPrimary.Checked; contact.Fax = txtContactFax.Text; contact.CompanyName = txtCompanyName.Text.Trim(); if (ddlContactType.SelectedIndex > 0) contact.CategoryID = Convert.ToInt32(ddlContactType.SelectedValue); else contact.CategoryID = null; contact.Address1 = txtAddress1.Text; contact.Address2 = txtAddress2.Text; if (ddlState.SelectedIndex > 0) contact.StateID = Convert.ToInt32(ddlState.SelectedValue); if (ddlCity.SelectedIndex > 0) contact.CityID = Convert.ToInt32(ddlCity.SelectedValue); if (ddlLossZip.SelectedIndex > 0) contact.ZipCodeID = Convert.ToInt32(ddlLossZip.SelectedValue); try { if (isNewContact) { using (TransactionScope scope = new TransactionScope()) { // save contact to contact table contact = ContactManager.Save(contact); claimContact = new ClaimContact(); claimContact.ClaimID = this.claimID; claimContact.ContactID = contact.ContactID; // save contact reference for claim claimContact = ClaimContactManager.Save(claimContact); // complete transaction scope.Complete(); } } else { // save contact to contact table contact = ContactManager.Save(contact); } lblMessage.Text = "Contact saved successfully."; lblMessage.CssClass = "ok"; } catch (Exception ex) { lblMessage.Text = "Contact not saved."; lblMessage.CssClass = "error"; Core.EmailHelper.emailError(ex); } finally { bindData(this.claimID); } }
protected void saveContact() { bool isNewContact = false; int contactID = Convert.ToInt32(ViewState["ContactID"]); Contact contact = null; ClaimContact claimContact = null; lblMessage.Text = string.Empty; if (contactID == 0) { // new contact contact = new Contact(); contact.ClientID = Core.SessionHelper.getClientId(); isNewContact = true; } else { contact = ContactManager.Get(contactID); } contact.FirstName = txtFirstName.Text; contact.LastName = txtLastName.Text; contact.ContactName = txtFirstName.Text + " " + txtLastName.Text; contact.Phone = txtContactPhone.Text; contact.Email = txtContactEmail.Text; contact.Phone = txtContactPhone.Text; contact.Mobile = txtMobilePhone.Text; contact.ContactTitle = txtContactTile.Text; contact.DepartmentName = txtDepartmentName.Text; contact.IsPrimary = cbxPrimary.Checked; contact.Fax = txtContactFax.Text; contact.CompanyName = txtCompanyName.Text.Trim(); if (ddlContactType.SelectedIndex > 0) { contact.CategoryID = Convert.ToInt32(ddlContactType.SelectedValue); } else { contact.CategoryID = null; } contact.Address1 = txtAddress1.Text; contact.Address2 = txtAddress2.Text; if (ddlState.SelectedIndex > 0) { contact.StateID = Convert.ToInt32(ddlState.SelectedValue); } if (ddlCity.SelectedIndex > 0) { contact.CityID = Convert.ToInt32(ddlCity.SelectedValue); } if (ddlLossZip.SelectedIndex > 0) { contact.ZipCodeID = Convert.ToInt32(ddlLossZip.SelectedValue); } try { if (isNewContact) { using (TransactionScope scope = new TransactionScope()) { // save contact to contact table contact = ContactManager.Save(contact); claimContact = new ClaimContact(); claimContact.ClaimID = this.claimID; claimContact.ContactID = contact.ContactID; // save contact reference for claim claimContact = ClaimContactManager.Save(claimContact); // complete transaction scope.Complete(); } } else { // save contact to contact table contact = ContactManager.Save(contact); } lblMessage.Text = "Contact saved successfully."; lblMessage.CssClass = "ok"; } catch (Exception ex) { lblMessage.Text = "Contact not saved."; lblMessage.CssClass = "error"; Core.EmailHelper.emailError(ex); } finally { bindData(this.claimID); } }