-
-
Notifications
You must be signed in to change notification settings - Fork 85
RG-T129 Delete Repo bug #449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unguarded external database call in Kody rule violation: Add try-catch blocks for external calls Prompt for LLMTalk 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(@" | ||
|
|
@@ -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; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unguarded
db.OpenAsync()call risks throwing an unhandled exception upon a database connection failure. WrapOpenAsyncand the subsequent transaction/ExecuteAsyncblock 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
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.