public static AutoMail Create (AutoMailType type, Organization org, Geography geo, Person author, string title, string body) { SwarmDb.GetDatabaseForWriting().SetAutoMail (type, org.Identity, geo.Identity, author == null ? 0 : author.Identity, title, body); return FromTypeOrganizationAndGeography (type, org, geo); }
public static AutoMail Create(AutoMailType type, Organization org, Geography geo, Person author, string title, string body) { SwarmDb.GetDatabaseForWriting().SetAutoMail(type, org.Identity, geo.Identity, author == null ? 0 : author.Identity, title, body); return(FromTypeOrganizationAndGeography(type, org, geo)); }
/// <summary> /// Basic constructor. /// </summary> public BasicAutoMail (int autoMailId, AutoMailType type, int organizationId, int geographyId, int authorPersonId, string title, string body) { this.autoMailId = autoMailId; this.type = type; this.organizationId = organizationId; this.geographyId = geographyId; this.authorPersonId = authorPersonId; this.title = title; this.body = body; }
/// <summary> /// Basic constructor. /// </summary> public BasicAutoMail(int autoMailId, AutoMailType type, int organizationId, int geographyId, int authorPersonId, string title, string body) { this.autoMailId = autoMailId; this.type = type; this.organizationId = organizationId; this.geographyId = geographyId; this.authorPersonId = authorPersonId; this.title = title; this.body = body; }
private static BasicAutoMail ReadAutoMailFromDataReader(DbDataReader reader) { int autoMailId = reader.GetInt32(0); AutoMailType type = (AutoMailType)Enum.Parse(typeof(AutoMailType), reader.GetString(1)); int geographyId = reader.GetInt32(3); int organizationId = reader.GetInt32(2); int authorPersonId = reader.GetInt32(4); // appear to be unused? string title = reader.GetString(5); string body = reader.GetString(6); return(new BasicAutoMail(autoMailId, type, organizationId, geographyId, authorPersonId, title, body)); }
public static AutoMail FromTypeOrganizationAndGeography(AutoMailType type, Organization org, Geography geo) { BasicAutoMail basic = SwarmDb.GetDatabaseForReading().GetAutoMail(type, org.Identity, geo.Identity); if (basic == null) { return(null); } if (basic.Body.Trim().Length < 3) { return(null); // If there is no body, there is no mail } return(FromBasic(basic)); }
public static AutoMail FromTypeOrganizationAndGeography (AutoMailType type, Organization org, Geography geo) { BasicAutoMail basic = SwarmDb.GetDatabaseForReading().GetAutoMail (type, org.Identity, geo.Identity); if (basic == null) { return null; } if (basic.Body.Trim().Length < 3) { return null; // If there is no body, there is no mail } return FromBasic (basic); }
public int SetAutoMail (AutoMailType type, int organizationId, int geographyId, int authorPersonId, string title, string body) { using (DbConnection connection = GetMySqlDbConnection()) { connection.Open(); DbCommand command = GetDbCommand("SetAutoMail", connection); command.CommandType = CommandType.StoredProcedure; AddParameterWithName(command, "autoMailType", type.ToString()); AddParameterWithName(command, "organizationId", organizationId); AddParameterWithName(command, "geographyId", geographyId); AddParameterWithName(command, "authorPersonId", authorPersonId); AddParameterWithName(command, "title", title); AddParameterWithName(command, "body", body); return Convert.ToInt32(command.ExecuteScalar()); } }
public int SetAutoMail(AutoMailType type, int organizationId, int geographyId, int authorPersonId, string title, string body) { using (DbConnection connection = GetMySqlDbConnection()) { connection.Open(); DbCommand command = GetDbCommand("SetAutoMail", connection); command.CommandType = CommandType.StoredProcedure; AddParameterWithName(command, "autoMailType", type.ToString()); AddParameterWithName(command, "organizationId", organizationId); AddParameterWithName(command, "geographyId", geographyId); AddParameterWithName(command, "authorPersonId", authorPersonId); AddParameterWithName(command, "title", title); AddParameterWithName(command, "body", body); return(Convert.ToInt32(command.ExecuteScalar())); } }
public BasicAutoMail GetAutoMail (AutoMailType type, int organizationId, int geographyId) { using (DbConnection connection = GetMySqlDbConnection()) { connection.Open(); DbCommand command = GetDbCommand( "select AutoMails.AutoMailId,AutoMailTypes.Name,AutoMails.OrganizationId,AutoMails.GeographyId,AutoMails.AuthorPersonId,Title,Body " + "FROM AutoMails JOIN AutoMailTypes USING (AutoMailTypeId) " + "WHERE AutoMailTypes.Name='" + type.ToString() + "' AND AutoMails.OrganizationId=" + organizationId.ToString() + " AND AutoMails.GeographyId=" + geographyId.ToString(), connection); using (DbDataReader reader = command.ExecuteReader()) { if (reader.Read()) { return ReadAutoMailFromDataReader(reader); } return null; // NULL returned - unusual; usually exception is thrown if not found } } }
public BasicAutoMail GetAutoMail(AutoMailType type, int organizationId, int geographyId) { using (DbConnection connection = GetMySqlDbConnection()) { connection.Open(); DbCommand command = GetDbCommand( "select AutoMails.AutoMailId,AutoMailTypes.Name,AutoMails.OrganizationId,AutoMails.GeographyId,AutoMails.AuthorPersonId,Title,Body " + "FROM AutoMails JOIN AutoMailTypes USING (AutoMailTypeId) " + "WHERE AutoMailTypes.Name='" + type.ToString() + "' AND AutoMails.OrganizationId=" + organizationId.ToString() + " AND AutoMails.GeographyId=" + geographyId.ToString(), connection); using (DbDataReader reader = command.ExecuteReader()) { if (reader.Read()) { return(ReadAutoMailFromDataReader(reader)); } return(null); // NULL returned - unusual; usually exception is thrown if not found } } }