/// <summary> /// Loads the given EmailTemplateTrigger object from the given database data reader. /// </summary> /// <param name="emailTemplateTrigger">The EmailTemplateTrigger object to load.</param> /// <param name="dr">The database data reader to read data from.</param> public static void LoadDataReader(EmailTemplateTrigger emailTemplateTrigger, IDataReader dr) { //SET FIELDS FROM ROW DATA emailTemplateTrigger.EmailTemplateId = dr.GetInt32(0); emailTemplateTrigger.StoreEventId = dr.GetInt32(1); emailTemplateTrigger.IsDirty = false; }
public static PersistentCollection <EmailTemplateTrigger> LoadForStoreEvent(StoreEvent storeEvent) { PersistentCollection <EmailTemplateTrigger> EmailTemplateTriggerCollection = new PersistentCollection <EmailTemplateTrigger>(); //CREATE THE DYNAMIC SQL TO LOAD OBJECT StringBuilder selectQuery = new StringBuilder(); //GET RECORDS STARTING AT FIRST ROW selectQuery.Append("SELECT StoreEventId, EmailTemplateId"); selectQuery.Append(" FROM ac_EmailTemplateTriggers"); selectQuery.Append(" WHERE StoreEventId = @storeEventId"); Database database = Token.Instance.Database; DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString()); database.AddInParameter(selectCommand, "@storeEventId", System.Data.DbType.Int32, (int)storeEvent); //EXECUTE THE COMMAND using (IDataReader dr = database.ExecuteReader(selectCommand)) { while (dr.Read()) { EmailTemplateTrigger storeEventTrigger = new EmailTemplateTrigger(); //SET FIELDS FROM ROW DATA storeEventTrigger.StoreEventId = dr.GetInt32(0); storeEventTrigger.EmailTemplateId = dr.GetInt32(1); storeEventTrigger.IsDirty = false; EmailTemplateTriggerCollection.Add(storeEventTrigger); } dr.Close(); } return(EmailTemplateTriggerCollection); }
public static EmailTemplateTrigger Load(Int32 emailTemplateId, Int32 storeEventId) { EmailTemplateTrigger emailTemplateTrigger = new EmailTemplateTrigger(); if (emailTemplateTrigger.Load(emailTemplateId, storeEventId)) { return(emailTemplateTrigger); } return(null); }
public static bool Delete(Int32 emailTemplateId, Int32 storeEventId) { EmailTemplateTrigger emailTemplateTrigger = new EmailTemplateTrigger(); if (emailTemplateTrigger.Load(emailTemplateId, storeEventId)) { return(emailTemplateTrigger.Delete()); } return(false); }
public static EmailTemplateTriggerCollection LoadForEmailTemplate(Int32 emailTemplateId, int maximumRows, int startRowIndex, string sortExpression) { //CREATE THE DYNAMIC SQL TO LOAD OBJECT StringBuilder selectQuery = new StringBuilder(); selectQuery.Append("SELECT"); if (maximumRows > 0) { selectQuery.Append(" TOP " + (startRowIndex + maximumRows).ToString()); } selectQuery.Append(" " + EmailTemplateTrigger.GetColumnNames(string.Empty)); selectQuery.Append(" FROM ac_EmailTemplateTriggers"); selectQuery.Append(" WHERE EmailTemplateId = @emailTemplateId"); if (!string.IsNullOrEmpty(sortExpression)) { selectQuery.Append(" ORDER BY " + sortExpression); } Database database = Token.Instance.Database; DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString()); database.AddInParameter(selectCommand, "@emailTemplateId", System.Data.DbType.Int32, emailTemplateId); //EXECUTE THE COMMAND EmailTemplateTriggerCollection results = new EmailTemplateTriggerCollection(); int thisIndex = 0; int rowCount = 0; using (IDataReader dr = database.ExecuteReader(selectCommand)) { while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows))) { if (thisIndex >= startRowIndex) { EmailTemplateTrigger emailTemplateTrigger = new EmailTemplateTrigger(); EmailTemplateTrigger.LoadDataReader(emailTemplateTrigger, dr); results.Add(emailTemplateTrigger); rowCount++; } thisIndex++; } dr.Close(); } return(results); }
public static SaveResult Insert(EmailTemplateTrigger emailTemplateTrigger) { return(emailTemplateTrigger.Save()); }
public static bool Delete(EmailTemplateTrigger emailTemplateTrigger) { return(emailTemplateTrigger.Delete()); }