// ZeroOrOneToMany public void LoadEmailQueues(MailingTemplate obj) { if (obj.EmailQueues != null) { _emailQueuesProperty = obj.EmailQueues.CurrentDTO; } }
public void LoadUpdatedByApplicationUser(MailingTemplate obj) { if (obj.UpdatedByApplicationUser != null) { _updatedByApplicationUserProperty = obj.UpdatedByApplicationUser.CurrentDTO; } }
public static MailingTemplate GetMailingTemplate(Func <IDataReader, MailingTemplate> rowParser, SqlDataReader reader) { MailingTemplate obj = rowParser(reader); obj.InitDTO(); obj.IsDirty = false; obj.IsNew = false; return(obj); }
public MailingTemplate CopyDTO(MailingTemplate obj) { obj.MailingTemplateID = this.MailingTemplateID; obj.Description = this.Description; obj.MailingText = this.MailingText; obj.MailingSubject = this.MailingSubject; obj.MailingFrom = this.MailingFrom; return(obj); }
public void Child_Update(MailingTemplate mailingTemplate, SqlConnection connection, SqlTransaction trans) { bool cancel = false; OnChildUpdating(mailingTemplate, connection, ref cancel, trans); if (cancel) { return; } if (connection.State != ConnectionState.Open) { connection.Open(); } using (var command = new SqlCommand("[dbo].[spCFM_EmailQueue_Update]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_EmailQueueID", this.EmailQueueID); command.Parameters.AddWithValue("@p_MailingTemplateID", ADOHelper.NullCheck(mailingTemplate != null ? mailingTemplate.MailingTemplateID : this.MailingTemplateID)); command.Parameters.AddWithValue("@p_SendTo", ADOHelper.NullCheck(this.SendTo)); command.Parameters.AddWithValue("@p_MailingText", ADOHelper.NullCheck(this.MailingText)); command.Parameters.AddWithValue("@p_MailingSubject", ADOHelper.NullCheck(this.MailingSubject)); command.Parameters.AddWithValue("@p_MailingFrom", ADOHelper.NullCheck(this.MailingFrom)); command.Parameters.AddWithValue("@p_RequestedDate", this.RequestedDate); command.Parameters.AddWithValue("@p_ProcessedDate", ADOHelper.NullCheck(this.ProcessedDate)); command.Parameters.AddWithValue("@p_ProcessResult", ADOHelper.NullCheck(this.ProcessResult)); //result: The number of rows changed, inserted, or deleted. -1 for select statements; 0 if no rows were affected, or the statement failed. int result = command.ExecuteNonQuery(); if (result == 0) { throw new DBConcurrencyException("The entity is out of date on the client. Please update the entity and try again. This could also be thrown if the sql statement failed to execute."); } // Update foreign keys values. This code will update the values passed in from the parent only if no errors occurred after executing the query. if (mailingTemplate != null && mailingTemplate.MailingTemplateID != this.MailingTemplateID) { _mailingTemplateIDProperty = mailingTemplate.MailingTemplateID; } } // A child relationship exists on this Business Object but its type is not a child type (E.G. EditableChild). // TODO: Please override OnChildUpdated() and update this child manually. // UpdateChildren(this, connection); OnChildUpdated(); }
public void Child_Insert(MailingTemplate mailingTemplate, SqlConnection connection, SqlTransaction trans) { bool cancel = false; OnChildInserting(mailingTemplate, connection, ref cancel, trans); if (cancel) { return; } if (connection.State != ConnectionState.Open) { connection.Open(); } using (var command = new SqlCommand("[dbo].[spCFM_EmailQueue_Insert]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_EmailQueueID", this.EmailQueueID); command.Parameters["@p_EmailQueueID"].Direction = ParameterDirection.Output; command.Parameters.AddWithValue("@p_MailingTemplateID", ADOHelper.NullCheck(mailingTemplate != null ? mailingTemplate.MailingTemplateID : this.MailingTemplateID)); command.Parameters.AddWithValue("@p_SendTo", ADOHelper.NullCheck(this.SendTo)); command.Parameters.AddWithValue("@p_MailingText", ADOHelper.NullCheck(this.MailingText)); command.Parameters.AddWithValue("@p_MailingSubject", ADOHelper.NullCheck(this.MailingSubject)); command.Parameters.AddWithValue("@p_MailingFrom", ADOHelper.NullCheck(this.MailingFrom)); command.Parameters.AddWithValue("@p_RequestedDate", this.RequestedDate); command.Parameters.AddWithValue("@p_ProcessedDate", ADOHelper.NullCheck(this.ProcessedDate)); command.Parameters.AddWithValue("@p_ProcessResult", ADOHelper.NullCheck(this.ProcessResult)); command.ExecuteNonQuery(); // Update identity primary key value. _emailQueueIDProperty = (System.Int32)command.Parameters["@p_EmailQueueID"].Value; // Update foreign keys values. This code will update the values passed in from the parent only if no errors occurred after executing the query. if (mailingTemplate != null && mailingTemplate.MailingTemplateID != this.MailingTemplateID) { _mailingTemplateIDProperty = mailingTemplate.MailingTemplateID; } } // A child relationship exists on this Business Object but its type is not a child type (E.G. EditableChild). // TODO: Please override OnChildInserted() and insert this child manually. // UpdateChildren(this, connection); OnChildInserted(); }
protected void UpdateChildren(MailingTemplate parent, SqlConnection connection, SqlTransaction trans) { if (_emailQueuesPropertyChecked) { if (_emailQueuesProperty != null) { foreach (EmailQueue obj in _emailQueuesProperty) { if (obj.IsNew) { obj.Child_Insert(parent, connection, trans); } else { if (obj.IsDirty || obj.IsChildDirty()) { obj.Child_Update(parent, connection, trans); } } } } } }
/// <summary> /// CodeSmith generated stub method that is called when updating the child <see cref="EmailQueue"/> object. /// </summary> /// <param name="connection"></param> /// <param name="cancel">Value returned from the method indicating whether the object insertion should proceed.</param> partial void OnChildUpdating(MailingTemplate mailingTemplate, SqlConnection connection, ref bool cancel, SqlTransaction trans);
/// <summary> /// Creates a new object of type <see cref="MailingTemplate"/>. /// </summary> /// <returns>Returns a newly instantiated collection of type <see cref="MailingTemplate"/>.</returns> public static MailingTemplate NewMailingTemplate() { MailingTemplate obj = new MailingTemplate(); return(obj); }
// [Transactional(TransactionalTypes.TransactionScope)] protected void DataPortal_Update() { bool cancel = false; OnUpdating(ref cancel); if (cancel) { return; } if (OriginalMailingTemplateID != MailingTemplateID) { // Insert new child. MailingTemplate item = new MailingTemplate { MailingTemplateID = MailingTemplateID, Description = Description, MailingText = MailingText, MailingSubject = MailingSubject, MailingFrom = MailingFrom, CreatedBy = CreatedBy, CreatedOn = CreatedOn }; if (UpdatedBy.HasValue) { item.UpdatedBy = UpdatedBy.Value; } if (UpdatedOn.HasValue) { item.UpdatedOn = UpdatedOn.Value; } item.DataPortal_Update(); // Mark editable child lists as dirty. This code may need to be updated to one-to-one relationships. foreach (EmailQueue itemToUpdate in EmailQueues) { itemToUpdate.MailingTemplateID = MailingTemplateID; } // Create a new connection. using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { UpdateChildren(this, connection, trans); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } //FieldManager.UpdateChildren(this, connection); } // Delete the old. var criteria = new MailingTemplateCriteria { MailingTemplateID = OriginalMailingTemplateID }; DataPortal_Delete(criteria); // Mark the original as the new one. OriginalMailingTemplateID = MailingTemplateID; OnUpdated(); return; } using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { using (var command = new SqlCommand("[dbo].[spCFM_MailingTemplate_Update]", connection, trans)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_OriginalMailingTemplateID", this.OriginalMailingTemplateID); command.Parameters.AddWithValue("@p_MailingTemplateID", this.MailingTemplateID); command.Parameters.AddWithValue("@p_Description", ADOHelper.NullCheck(this.Description)); command.Parameters.AddWithValue("@p_MailingText", ADOHelper.NullCheck(this.MailingText)); command.Parameters.AddWithValue("@p_MailingSubject", ADOHelper.NullCheck(this.MailingSubject)); command.Parameters.AddWithValue("@p_MailingFrom", ADOHelper.NullCheck(this.MailingFrom)); command.Parameters.AddWithValue("@p_CreatedBy", this.CreatedBy); command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn); command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(this.UpdatedBy)); command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn)); //result: The number of rows changed, inserted, or deleted. -1 for select statements; 0 if no rows were affected, or the statement failed. int result = command.ExecuteNonQuery(); if (result == 0) { throw new DBConcurrencyException("The entity is out of date on the client. Please update the entity and try again. This could also be thrown if the sql statement failed to execute."); } _originalMailingTemplateIDProperty = this.MailingTemplateID; } UpdateChildren(this, connection, trans); //FieldManager.UpdateChildren(this, connection); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw; } } OnUpdated(); }