/// <summary> /// Fills EmailHistory object /// </summary> /// <param name="emailHistoryObject">The object to be filled</param> /// <param name="reader">The reader to use to fill a single object</param> /// <param name="start">The ordinal position from which to start reading the reader</param> protected void FillObject(EmailHistoryBase emailHistoryObject, SqlDataReader reader, int start) { emailHistoryObject.Id = reader.GetInt32(start + 0); if (!reader.IsDBNull(1)) { emailHistoryObject.TemplateKey = reader.GetString(start + 1); } if (!reader.IsDBNull(2)) { emailHistoryObject.ToEmail = reader.GetString(start + 2); } if (!reader.IsDBNull(3)) { emailHistoryObject.CcEmail = reader.GetString(start + 3); } if (!reader.IsDBNull(4)) { emailHistoryObject.BccEmail = reader.GetString(start + 4); } if (!reader.IsDBNull(5)) { emailHistoryObject.FromEmail = reader.GetString(start + 5); } if (!reader.IsDBNull(6)) { emailHistoryObject.FromName = reader.GetString(start + 6); } if (!reader.IsDBNull(7)) { emailHistoryObject.EmailSubject = reader.GetString(start + 7); } if (!reader.IsDBNull(8)) { emailHistoryObject.EmailBodyContent = reader.GetString(start + 8); } if (!reader.IsDBNull(9)) { emailHistoryObject.EmailSentDate = reader.GetDateTime(start + 9); } if (!reader.IsDBNull(10)) { emailHistoryObject.IsSystemAutoSent = reader.GetBoolean(start + 10); } if (!reader.IsDBNull(11)) { emailHistoryObject.IsRead = reader.GetBoolean(start + 11); } if (!reader.IsDBNull(12)) { emailHistoryObject.ReadCount = reader.GetInt32(start + 12); } if (!reader.IsDBNull(13)) { emailHistoryObject.LastUpdatedDate = reader.GetDateTime(start + 13); } FillBaseObject(emailHistoryObject, reader, (start + 14)); emailHistoryObject.RowState = BaseBusinessEntity.RowStateEnum.NormalRow; }
/// <summary> /// Add common parameters before calling a procedure /// </summary> /// <param name="cmd">command object, where parameters will be added</param> /// <param name="emailHistoryObject"></param> private void AddCommonParams(SqlCommand cmd, EmailHistoryBase emailHistoryObject) { AddParameter(cmd, pNVarChar(EmailHistoryBase.Property_TemplateKey, 250, emailHistoryObject.TemplateKey)); AddParameter(cmd, pNVarChar(EmailHistoryBase.Property_ToEmail, 250, emailHistoryObject.ToEmail)); AddParameter(cmd, pNVarChar(EmailHistoryBase.Property_CcEmail, 250, emailHistoryObject.CcEmail)); AddParameter(cmd, pNVarChar(EmailHistoryBase.Property_BccEmail, 250, emailHistoryObject.BccEmail)); AddParameter(cmd, pNVarChar(EmailHistoryBase.Property_FromEmail, 250, emailHistoryObject.FromEmail)); AddParameter(cmd, pNVarChar(EmailHistoryBase.Property_FromName, 250, emailHistoryObject.FromName)); AddParameter(cmd, pNVarChar(EmailHistoryBase.Property_EmailSubject, 250, emailHistoryObject.EmailSubject)); AddParameter(cmd, pNVarChar(EmailHistoryBase.Property_EmailBodyContent, emailHistoryObject.EmailBodyContent)); AddParameter(cmd, pDateTime(EmailHistoryBase.Property_EmailSentDate, emailHistoryObject.EmailSentDate)); AddParameter(cmd, pBool(EmailHistoryBase.Property_IsSystemAutoSent, emailHistoryObject.IsSystemAutoSent)); AddParameter(cmd, pBool(EmailHistoryBase.Property_IsRead, emailHistoryObject.IsRead)); AddParameter(cmd, pInt32(EmailHistoryBase.Property_ReadCount, emailHistoryObject.ReadCount)); AddParameter(cmd, pDateTime(EmailHistoryBase.Property_LastUpdatedDate, emailHistoryObject.LastUpdatedDate)); }
/// <summary> /// Updates EmailHistory /// </summary> /// <param name="emailHistoryObject">Object to be updated</param> /// <returns>Number of rows affected</returns> public long Update(EmailHistoryBase emailHistoryObject) { try { SqlCommand cmd = GetSPCommand(UPDATEEMAILHISTORY); AddParameter(cmd, pInt32(EmailHistoryBase.Property_Id, emailHistoryObject.Id)); AddCommonParams(cmd, emailHistoryObject); long result = UpdateRecord(cmd); if (result > 0) { emailHistoryObject.RowState = BaseBusinessEntity.RowStateEnum.NormalRow; } return(result); } catch (SqlException x) { throw new ObjectUpdateException(emailHistoryObject, x); } }
/// <summary> /// Inserts EmailHistory /// </summary> /// <param name="emailHistoryObject">Object to be inserted</param> /// <returns>Number of rows affected</returns> public long Insert(EmailHistoryBase emailHistoryObject) { try { SqlCommand cmd = GetSPCommand(INSERTEMAILHISTORY); AddParameter(cmd, pInt32Out(EmailHistoryBase.Property_Id)); AddCommonParams(cmd, emailHistoryObject); long result = InsertRecord(cmd); if (result > 0) { emailHistoryObject.RowState = BaseBusinessEntity.RowStateEnum.NormalRow; emailHistoryObject.Id = (Int32)GetOutParameter(cmd, EmailHistoryBase.Property_Id); } return(result); } catch (SqlException x) { throw new ObjectInsertException(emailHistoryObject, x); } }
/// <summary> /// Fills EmailHistory object /// </summary> /// <param name="emailHistoryObject">The object to be filled</param> /// <param name="reader">The reader to use to fill a single object</param> protected void FillObject(EmailHistoryBase emailHistoryObject, SqlDataReader reader) { FillObject(emailHistoryObject, reader, 0); }