Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ public async Task<bool> DeleteDepartmentAndUsersAsync(int departmentId)

if (Config.DataConfig.DatabaseType == DatabaseTypes.SqlServer)
{
using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString))
using (var db = new SqlConnection(DataConfig.CoreConnectionString))
{
await db.OpenAsync();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Kody Rules high

Unguarded db.OpenAsync() call risks throwing an unhandled exception upon a database connection failure. Wrap OpenAsync and the subsequent transaction/ExecuteAsync block in a try/catch that logs context and handles or rethrows the error appropriately to comply with Rule [1].

Kody rule violation: Handle async operations with proper error handling

Prompt for LLM

File Repositories/Resgrid.Repositories.DataRepository/DeleteRepository.cs:

Line 29:

Unguarded `db.OpenAsync()` call risks throwing an unhandled exception upon a database connection failure. Wrap `OpenAsync` and the subsequent transaction/`ExecuteAsync` block in a try/catch that logs context and handles or rethrows the error appropriately to comply with Rule [1].

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Kody Rules high

Unguarded external database call in db.OpenAsync() omits mandated error mapping per Rule [27]. Wrap the OpenAsync call in a try/catch, log the relevant departmentId identifier, and map exceptions to an application-level error or rethrow with context.

Kody rule violation: Add try-catch blocks for external calls

Prompt for LLM

File Repositories/Resgrid.Repositories.DataRepository/DeleteRepository.cs:

Line 29:

Unguarded external database call in `db.OpenAsync()` omits mandated error mapping per Rule [27]. Wrap the `OpenAsync` call in a try/catch, log the relevant `departmentId` identifier, and map exceptions to an application-level error or rethrow with context.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.


using (var transaction = db.BeginTransaction())
{
var result = await db.ExecuteAsync(@"
Expand Down Expand Up @@ -171,13 +173,13 @@ DELETE FROM [dbo].[MessageRecipients] WHERE MessageId IN (SELECT MessageId FROM
DELETE FROM [dbo].[AspNetUsersExt] WHERE UserId = @ManagingUserId
DELETE FROM [dbo].[AspNetUsers] WHERE Id = @ManagingUserId
",
new { DepartmentId = departmentId });
new { DepartmentId = departmentId }, transaction);

transaction.Commit();
}
}

return false;
return true;
}

return false;
Expand Down
Loading