public static IEnumerable<Permission> Select_All() { IEnumerable<Permission> permissions = null; DataTable table = null; DataLayer.MySQL mySql = null; try { mySql = new DataLayer.MySQL(DatConnectionString); table = mySql.GetDataTable(StoredProcedures.Permissions_Select_All.ToString()); if (table != null) permissions = table.Rows.Select<Permission>(); } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading permissions.", ex); } finally { if (mySql != null) mySql.Dispose(); } return permissions; }
public ValueObject.Column SelectByColumneName(string databaseName, string tableName, string columnName) { ValueObject.Column column = null; System.Data.DataRow row = null; DataLayer.MySQL mySql = null; try { mySql = new DataLayer.MySQL(ConnectionString); row = mySql.GetDataRow(StoredProcedures.Column_Select_ByColumnName.ToString(), "@DatabaseName", databaseName, "@TableName", tableName, "@ColumnName", columnName); if (row != null) column = Fill(row); } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading column.", ex); } finally { if (mySql != null) mySql.Dispose(); } return column; }
public static IEnumerable<AssetSubscription> ByPublisherAssetGuid(Guid publisherAssetGuid) { IEnumerable<AssetSubscription> assetSubscriptions = null; DataTable table = null; DataLayer.MySQL mySql = null; try { mySql = new DataLayer.MySQL(ConnectionString); table = mySql.GetDataTable(StoredProcedures.AssetSubscriptions_Select_ByPublisherAssetGuid.ToString(), "_PublisherAssetGuid", publisherAssetGuid); if (table != null) assetSubscriptions = table.Rows.Select<AssetSubscription>( ); } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading asset subscriptions.", ex); } finally { if (mySql != null) mySql.Dispose(); } return assetSubscriptions; }
public static IEnumerable<RolePermission> ByPermissionId(int permissionId ) { IEnumerable<RolePermission> rolePermissions = null; DataTable table = null; DataLayer.MySQL mySql = null; try { mySql = new DataLayer.MySQL(DatConnectionString); table = mySql.GetDataTable(StoredProcedures.RolePermissions_Select_ByPermissionId.ToString(), "_PermissionId", permissionId); if (table != null) rolePermissions = table.Rows.Select<RolePermission>( ); } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading asset permissions.", ex); } finally { if (mySql != null) mySql.Dispose(); } return rolePermissions; }
public List<ValueObject.Table> SelectByDatabaseName(string databaseName) { List<ValueObject.Table> tables = null; System.Data.DataTable table= null; DataLayer.MySQL mySql = null; try { mySql = new DataLayer.MySQL(ConnectionString); table = mySql.GetDataTable(StoredProcedures.Table_Select_ByDatabaseName.ToString(), "@DatabaseName", databaseName); if (table != null) { tables = new List<ValueObject.Table>(); foreach (System.Data.DataRow row in table.Rows) tables.Add(Fill(row)); } } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading tables.", ex); } finally { if (mySql != null) mySql.Dispose(); } return tables; }
public static bool IsSubscribed(Guid assetGuid,Guid userGuid) { bool success = false; DataLayer.MySQL mySql = null; try { mySql = new DataLayer.MySQL(DatConnectionString); return (bool)mySql.ExecuteScalarObject(StoredProcedures.Subscriptions_Insert.ToString(), "_AssetGuid", assetGuid, "_UserGuid", userGuid); } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error saving subscription.", ex); } finally { if (mySql != null) mySql.Dispose(); } }
protected override bool Save() { bool success = false; DataLayer.MySQL mySql = null; try { mySql = new DataLayer.MySQL(ConnectionString); AssetId = (int)mySql.ExecuteScalar(StoredProcedures.Assets_Update.ToString(), "_AssetName", AssetName, "_AssetGuid", AssetGuid, "_AssetCode", AssetCode); success = AssetId > 1; } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error saving asset.", ex); } finally { if (mySql != null) mySql.Dispose(); } return success; }
protected override bool Insert() { bool success = false; DataLayer.MySQL mySql = null; try { mySql = new DataLayer.MySQL(ConnectionString); AssetSubscriptionId = (int)mySql.ExecuteScalar(StoredProcedures.AssetSubscriptions_Insert.ToString(), "_SubscriberAssetGuid", SubscriberAssetGuid, "_PublisherAssetGuid", PublisherAssetGuid, "_CreatedBy", CreatedBy); success = AssetSubscriptionId > 1; } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error saving asset subscription.", ex); } finally { if (mySql != null) mySql.Dispose(); } return success; }
protected override bool Save() { bool success = false; DataLayer.MySQL mySql = null; try { mySql = new DataLayer.MySQL(ConnectionString); RoleId = (int)mySql.ExecuteScalar(StoredProcedures.Roles_Update_ByRoleId.ToString(), "_RoleName", RoleName, "_RoleDescription", RoleDescription); success = RoleId > 0; } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error role user.", ex); } finally { if (mySql != null) mySql.Dispose(); } return success; }
protected override bool Insert() { bool success = false; DataLayer.MySQL mySql = null; try { mySql = new DataLayer.MySQL(ConnectionString); LogId = (int)mySql.ExecuteScalar(StoredProcedures.Logs_Insert.ToString(), "_RequestId", RequestId, "_LogType", LogType, "_Title", Title, "_Text", Text, "_ReferenceKey", ReferenceKey, "_Action", Action, "_Success", Success); success = LogId > 1; } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error saving log.", ex); } finally { if (mySql != null) mySql.Dispose(); } return success; }
protected override bool Insert() { bool success = false; DataLayer.MySQL mySql = null; try { mySql = new DataLayer.MySQL(ConnectionString); RolePermissionId = (int)mySql.ExecuteScalar(StoredProcedures.RolePermissions_Insert.ToString(), "_RoleId", RoleId, "_PermissionId", PermissionId, "_CreatedBy", CreatedBy); success = RolePermissionId > 1; } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error saving role permission.", ex); } finally { if (mySql != null) mySql.Dispose(); } return success; }
public Boolean Load(long postalcode_id) { Boolean success = false; DataLayer.MySQL mySQL = null; DataRow row = null; try { mySQL = new DataLayer.MySQL(ConnectionString); row = mySQL.GetDataRow(DataLayer.StoredProcedures.postal_codes_std_get_id, "@_id_postal_code", postalcode_id); if (row != null) success = Load(row); } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading postal code.", ex); } finally { if (mySQL != null) mySQL.Dispose(); } return success; }
public static List<PostalCodeInfo> LoadPostalCodes(string postal_code, string connectionString) { Boolean success = false; DataLayer.MySQL mySQL = null; DataTable dt = null; List<PostalCodeInfo> postalcodes = new List<PostalCodeInfo>(); ; try { mySQL = new DataLayer.MySQL(connectionString); dt = mySQL.GetDataTable(DataLayer.StoredProcedures.postal_codes_std_get_postal_code, "@_postal_code", postal_code); if (dt != null) foreach (System.Data.DataRow row in dt.Rows) { PostalCodeInfo postalcode = new PostalCodeInfo(connectionString); if (postalcode.Load(row) && postalcode.PostalCodeID > 0) postalcodes.Add(postalcode); } } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading postal code.", ex); } finally { if (mySQL != null) mySQL.Dispose(); } return postalcodes; }
protected override bool Insert() { bool success = false; DataLayer.MySQL mySql = null; try { mySql = new DataLayer.MySQL(ConnectionString); UserEventId = mySql.ExecuteScalar(StoredProcedures.UserEvents_Update.ToString(), "_UserEventId", UserEventId, "_UserEventReferenceKey", UserEventReferenceKey, "_UserGuid", UserGuid, "_EventId", EventId, "_UserEventDescription", Description); success = UserEventId > 0; } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error saving user event.", ex); } finally { if (mySql != null) mySql.Dispose(); } return success; }
protected override bool Insert() { bool success = false; DataLayer.MySQL mySql = null; string truncatedResult = Result; try { if (Result != null) if (Result.ToCharArray().Length >= 20000) truncatedResult = Result.Substring(0, 20000); mySql = new DataLayer.MySQL(ConnectionString); RequestId = mySql.ExecuteScalar(StoredProcedures.Requests_Insert.ToString(), "_Version", Version, "_AssetCode", AssetCode, "_Service", Service, "_EndPoint", EndPoint, "_Parameters", Parameters, "_Method", Method, "_UserGuid", UserGuid, "_IpAddress", IpAddress, "_Url", Url, "_Headers", Headers, "_HttpAuth", HttpAuth, "_Language", Language, "_Referrer", Referrer, "_UserAgent", UserAgent, "_Cookies", Cookies, "_InputStream", InputStream, "_ContentType", ContentType, "_SubscriberAssetGuid", SubscriberAssetGuid, "_AcceptType", AcceptType, "_Result", truncatedResult, "_ServerIpAddress", ServerIpAddress); success = RequestId > 0; } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error saving request.", ex); } finally { if (mySql != null) mySql.Dispose(); } return success; }
protected override bool Save() { bool success = false; DataLayer.MySQL mySql = null; string truncatedResult = Result; try { if (Result != null) if (Result.ToCharArray().Length >= 20000) truncatedResult = Result.Substring(0, 20000); mySql = new DataLayer.MySQL(ConnectionString); RequestId = mySql.ExecuteScalar(StoredProcedures.Requests_Update.ToString(), "_RequestId", RequestId, "_Result", truncatedResult ); success = RequestId > 0; } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error saving request.", ex); } finally { if (mySql != null) mySql.Dispose(); } return success; }
public static User Authenticate(string emailAddress, string password) { DataRow row = null; User user = null; DataLayer.MySQL mySql = null; try { mySql = new DataLayer.MySQL(DatConnectionString); row = mySql.GetDataRow(StoredProcedures.Users_Authenticate.ToString(), "_EmailAddress", emailAddress, "_Password", password); if (row == null) return user; user = new User(); if (!row.TryParse<User>(user) || user.UserId < 1) user = null; } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading user.", ex); } finally { if (mySql != null) mySql.Dispose(); } return user; }
public bool ByRoleId(int roleId) { bool success = false; DataRow row = null; DataLayer.MySQL mySql = null; try { mySql = new DataLayer.MySQL(ConnectionString); row = mySql.GetDataRow(StoredProcedures.Roles_Select_ByRoleId.ToString(), "_RoleId", roleId); if (row != null) success = row.TryParse<Role>(this) && RoleId > 0; } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading role.", ex); } finally { if (mySql != null) mySql.Dispose(); } return success; }
public bool ByUserGuid(Guid userGuid) { bool success = false; DataRow row = null; DataLayer.MySQL mySql = null; try { mySql = new DataLayer.MySQL(ConnectionString); row = mySql.GetDataRow(StoredProcedures.Users_Select_ByUserGuid.ToString(), "_UserGuid", userGuid); if (row != null) success = row.TryParse<User>(this) && UserId > 0; } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading user.", ex); } finally { if (mySql != null) mySql.Dispose(); } return success; }
protected override bool Save() { bool success = false; DataLayer.MySQL mySql = null; try { mySql = new DataLayer.MySQL(ConnectionString); UserId = mySql.ExecuteScalar(StoredProcedures.Users_Update.ToString(), "_UserId", UserId, "_EmailAddress", EmailAddress, "_FirstName", FirstName, "_LastName", LastName, "_UserGuid", UserGuid, "_Password", Password, "_Active", Active, "_RoleId", RoleId); success = UserId > 0; } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error saving user.", ex); } finally { if (mySql != null) mySql.Dispose(); } return success; }
public static IEnumerable<Subscription> ByUserGuid(Guid userGuid) { IEnumerable<Subscription> subscriptions = null; DataTable table = null; DataLayer.MySQL mySql = null; try { mySql = new DataLayer.MySQL(DatConnectionString); table = mySql.GetDataTable(StoredProcedures.Subscriptions_Select_ByUserGuid.ToString(), "_UserGuid", userGuid); if (table != null) subscriptions = table.Rows.Select<Subscription>(); } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading subscriptions.", ex); } finally { if (mySql != null) mySql.Dispose(); } return subscriptions; }
public bool ByAssetCode(string assetCode) { bool success = false; DataRow row = null; DataLayer.MySQL mySql = null; try { mySql = new DataLayer.MySQL(ConnectionString); row = mySql.GetDataRow(StoredProcedures.Assets_Select_ByAssetCode.ToString(), "_AssetCode", assetCode); if (row != null) success = row.TryParse<Asset>(this) && AssetId > 0; } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading asset.", ex); } finally { if (mySql != null) mySql.Dispose(); } return success; }
public static IEnumerable<AssetRole> ByRoleId(int roleId) { IEnumerable<AssetRole> assetRoles = null; DataTable table = null; DataLayer.MySQL mySql = null; try { mySql = new DataLayer.MySQL(DatConnectionString); table = mySql.GetDataTable(StoredProcedures.AssetRoles_Select_ByAssetGuid.ToString(), "_RoleId", roleId); if (table != null) assetRoles = table.Rows.Select<AssetRole>(); } catch (Exception ex) { throw new Exceptions.BusinessLogicException("Error loading asset roles.", ex); } finally { if (mySql != null) mySql.Dispose(); } return assetRoles; }