public static TMSContactUs Get(System.Int32 contactID) { DataSet ds; Database db; string sqlCommand; DbCommand dbCommand; TMSContactUs instance; instance = new TMSContactUs(); db = DatabaseFactory.CreateDatabase(); sqlCommand = "[dbo].gspTMSContactUs_SELECT"; dbCommand = db.GetStoredProcCommand(sqlCommand, contactID); // Get results. ds = db.ExecuteDataSet(dbCommand); // Verification. if (ds == null || ds.Tables[0].Rows.Count == 0) { throw new ApplicationException("Could not get TMSContactUs ID:" + contactID.ToString() + " from Database."); } // Return results. ds.Tables[0].TableName = TABLE_NAME; instance.MapFrom(ds.Tables[0].Rows[0]); return(instance); }
public static TMSContactUs[] Search(System.Int32?contactID, System.String contactName, System.String contactEmail, System.String contactPhone, System.String contactSubject, System.String contactComment, System.String contactReply, System.Int32?contactReplyStatus, System.Int32?contactStatus, System.DateTime?contactDate) { DataSet ds; Database db; string sqlCommand; DbCommand dbCommand; db = DatabaseFactory.CreateDatabase(); sqlCommand = "[dbo].gspTMSContactUs_SEARCH"; dbCommand = db.GetStoredProcCommand(sqlCommand, contactID, contactName, contactEmail, contactPhone, contactSubject, contactComment, contactReply, contactReplyStatus, contactStatus, contactDate); ds = db.ExecuteDataSet(dbCommand); ds.Tables[0].TableName = TABLE_NAME; return(TMSContactUs.MapFrom(ds)); }
public static TMSContactUs[] MapFrom(DataSet ds) { List <TMSContactUs> objects; // Initialise Collection. objects = new List <TMSContactUs>(); // Validation. if (ds == null) { throw new ApplicationException("Cannot map to dataset null."); } else if (ds.Tables[TABLE_NAME].Rows.Count == 0) { return(objects.ToArray()); } if (ds.Tables[TABLE_NAME] == null) { throw new ApplicationException("Cannot find table [dbo].[TMS_ContactUs] in DataSet."); } if (ds.Tables[TABLE_NAME].Rows.Count < 1) { throw new ApplicationException("Table [dbo].[TMS_ContactUs] is empty."); } // Map DataSet to Instance. foreach (DataRow dr in ds.Tables[TABLE_NAME].Rows) { TMSContactUs instance = new TMSContactUs(); instance.MapFrom(dr); objects.Add(instance); } // Return collection. return(objects.ToArray()); }
public static TMSContactUs[] MapFrom(DataSet ds) { List<TMSContactUs> objects; // Initialise Collection. objects = new List<TMSContactUs>(); // Validation. if (ds == null) throw new ApplicationException("Cannot map to dataset null."); else if (ds.Tables[TABLE_NAME].Rows.Count == 0) return objects.ToArray(); if (ds.Tables[TABLE_NAME] == null) throw new ApplicationException("Cannot find table [dbo].[TMS_ContactUs] in DataSet."); if (ds.Tables[TABLE_NAME].Rows.Count < 1) throw new ApplicationException("Table [dbo].[TMS_ContactUs] is empty."); // Map DataSet to Instance. foreach (DataRow dr in ds.Tables[TABLE_NAME].Rows) { TMSContactUs instance = new TMSContactUs(); instance.MapFrom(dr); objects.Add(instance); } // Return collection. return objects.ToArray(); }
public static TMSContactUs Get(System.Int32 contactID) { DataSet ds; Database db; string sqlCommand; DbCommand dbCommand; TMSContactUs instance; instance = new TMSContactUs(); db = DatabaseFactory.CreateDatabase(); sqlCommand = "[dbo].gspTMSContactUs_SELECT"; dbCommand = db.GetStoredProcCommand(sqlCommand, contactID); // Get results. ds = db.ExecuteDataSet(dbCommand); // Verification. if (ds == null || ds.Tables[0].Rows.Count == 0) throw new ApplicationException("Could not get TMSContactUs ID:" + contactID.ToString()+ " from Database."); // Return results. ds.Tables[0].TableName = TABLE_NAME; instance.MapFrom( ds.Tables[0].Rows[0] ); return instance; }