protected void SaveContactsNotes() { OMMDataContext context = new OMMDataContext(); ContactsNote entity = null; if (_IsEditMode) { entity = context.ContactsNotes.FirstOrDefault(P => P.ID == _ID && P.ContactID == _ContactID); //dao.GetByID(_ID); } else { entity = new ContactsNote(); entity.ContactID = _ContactID; context.ContactsNotes.InsertOnSubmit(entity); } //ddlContactID.SelectedValue.ToInt(); entity.Notes = txtNotes.Text; entity.ContactCommsTypeID = Convert.ToInt32(ddlCommType.SelectedValue); entity.ChangedByUserID = SessionCache.CurrentUser.ID; entity.ChangedOn = DateTime.Now; entity.CreatedByUsername = entity.ChangedByUsername = SessionCache.CurrentUser.UserName; context.SubmitChanges(); String url = String.Format("{0}?{1}={2}&{3}=True" , Request.Url.AbsolutePath , AppConstants.QueryString.CONTACT_ID , _ContactID , AppConstants.QueryString.SUCCESS_MSG); Response.Redirect(url); }
/// <summary> /// Binds ContactsNotes Info Requested through Query Strings /// </summary> protected void BindContactsNotesInfo() { OMMDataContext context = new OMMDataContext(); if (context.Contacts.FirstOrDefault(P => P.ID == _ContactID) == null) { ShowNotFoundMessage(); } else { if (_IsEditMode) { ContactsNote entity = context.ContactsNotes.FirstOrDefault(P => P.ID == _ID && P.ContactID == _ContactID);//dao.GetByID(_ID); if (entity == null) { ShowNotFoundMessage(); } else { //UtilityDAO dao = new UtilityDAO(); //DbParameter[] parameters = new[] { new DbParameter("@CommTypeID", entity.ContactCommsTypeID) }; ////DataSet ds = dao.GetPagedData(AppSQL.GET_BANK_DETAILS_BY_CONTACT, parameters, pageNumber, PAGE_SIZE, out totalRecord); //DataSet ds = dao.GetDataSet(AppSQL.GET_BANK_DETAILS_BY_CONTACT, parameters, false); //ddlContactID.SetSelectedItem(entity.ContactID.ToString()); txtNotes.Text = entity.Notes; ddlCommType.SetSelectedItem(entity.ContactCommsTypeID.ToString()); //txtChangedOn.Text = entity.ChangedOn.ToString(ConfigReader.CSharpCalendarDateFormat); //txtVersion.Text = entity.Version; //txtCreatedByUsername.Text = entity.CreatedByUsername; //txtChangedByUsername.Text = entity.ChangedByUsername; } } } }
public static int SavePersonnel(App.CustomModels.Personnel personnel, List <App.CustomModels.PersonnelTelephone> telephones, List <App.CustomModels.ConNote> ConNotes, List <App.CustomModels.PersonnelEmail> emails, List <App.CustomModels.PersonnelRole> roles) { OMMDataContext context = new OMMDataContext(); Contact contact = populateContact(personnel, context); ///Bind Telephones if (telephones != null && telephones.Count > 0) { foreach (App.CustomModels.PersonnelTelephone telephone in telephones) { TelephoneNumber phone = null; if (telephone.ID > 0) { phone = context.TelephoneNumbers.SingleOrDefault(P => P.ID == telephone.ID); } else { phone = new TelephoneNumber(); contact.TelephoneNumbers.Add(phone); } phone.Number = telephone.Number; phone.TypeID = telephone.TypeID; phone.ChangedByUserID = SessionCache.CurrentUser.ID; phone.ChangedOn = DateTime.Now; } } ///Bind Notes if (ConNotes != null && ConNotes.Count > 0) { foreach (App.CustomModels.ConNote conNote in ConNotes) { ContactsNote note = null; if (conNote.ID > 0) { note = context.ContactsNotes.SingleOrDefault(P => P.ID == conNote.ID); } else { note = new ContactsNote(); contact.ContactsNotes.Add(note); } note.Notes = conNote.Notes; if (conNote.CommsTypeID != null) { note.ContactCommsTypeID = Convert.ToInt32(conNote.CommsTypeID); } note.ChangedByUserID = SessionCache.CurrentUser.ID; note.ChangedOn = DateTime.Now; } } ///Bind Eamils if (emails != null && emails.Count > 0) { foreach (App.CustomModels.PersonnelEmail email in emails) { EmailAddress contactEmail = null; if (email.ID > 0) { contactEmail = context.EmailAddresses.SingleOrDefault(P => P.ID == email.ID); } else { contactEmail = new EmailAddress(); contact.EmailAddresses.Add(contactEmail); } contactEmail.Address = email.Email; contactEmail.ChangedByUserID = SessionCache.CurrentUser.ID; contactEmail.ChangedOn = DateTime.Now; } } ///Roles context.SubmitChanges(); return(contact.ID); }