/* Update */ public override void Update(Document doc, NorthwindConfig config, ref List<TransactionResult> result) { List<TransactionResult> transactionResult = new List<TransactionResult>(); EmailDocument emailDocument = doc as EmailDocument; #region check input values if (emailDocument == null) { result.Add(doc.SetTransactionStatus(TransactionStatus.UnRecoverableError, Resources.ErrorMessages_DocumentTypeNotSupported)); return; } // check id #endregion CustomerEmailsTableAdapter tableAdapter; Emails emailsDataset = new Emails(); Emails.CustomerEmailsRow emailsRow; tableAdapter = new CustomerEmailsTableAdapter(); using (OleDbConnection connection = new OleDbConnection(config.ConnectionString)) { connection.Open(); tableAdapter.Connection = connection; int recordCount = tableAdapter.FillBy(emailsDataset.CustomerEmails, Convert.ToInt32(emailDocument.Id)); if (recordCount == 0) { doc.SetTransactionStatus(TransactionStatus.UnRecoverableError, "Category does not exists"); return; } emailsRow = (Emails.CustomerEmailsRow)emailsDataset.CustomerEmails.Rows[0]; try { if (emailDocument.emailaddress.IsNull) emailsRow.SetEmailNull(); else emailsRow.Email = (string)emailDocument.emailaddress.Value; emailsRow.ModifyID = config.SequenceNumber; emailsRow.ModifyUser = config.CrmUser; } catch (Exception e) { emailDocument.Id = ""; #warning Check error message result.Add(emailDocument.SetTransactionStatus(TransactionStatus.UnRecoverableError, e.ToString())); return; } tableAdapter = new CustomerEmailsTableAdapter(); tableAdapter.Connection = connection; tableAdapter.Update(emailsDataset.CustomerEmails); } }
/* Get */ public override Document GetDocument(Identity identity, Token lastToken, NorthwindConfig config) { int recordCount; Emails emails = new Emails(); int id = Identity.GetId(identity); //string strId = Convert.ToString(id); using (OleDbConnection connection = new OleDbConnection(config.ConnectionString)) { CustomerEmailsTableAdapter tableAdapter; tableAdapter = new CustomerEmailsTableAdapter(); tableAdapter.Connection = connection; recordCount = tableAdapter.FillBy(emails.CustomerEmails, id); } if (recordCount == 0) return GetDeletedDocument(identity); return GetDocument((Emails.CustomerEmailsRow)emails.CustomerEmails[0], lastToken, config); }