-
-
Notifications
You must be signed in to change notification settings - Fork 80
RE1-T112 Bug fixes #322
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
RE1-T112 Bug fixes #322
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 |
|---|---|---|
|
|
@@ -102,8 +102,8 @@ where key.ToString().StartsWith("buttonText_") | |
| if (gpsValue == "on") | ||
| gps = true; | ||
|
|
||
| var noteType = int.Parse(form["noteType_" + i]); | ||
| var detailType = int.Parse(form["detailType_" + i]); | ||
| int.TryParse(form["noteType_" + i], out var noteType); | ||
| int.TryParse(form["detailType_" + i], out var detailType); | ||
|
Comment on lines
+105
to
+106
Contributor
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. Don’t silently coerce invalid On Line 105/106 and Line 288/289, failed parses currently become Proposed fix- int.TryParse(form["noteType_" + i], out var noteType);
- int.TryParse(form["detailType_" + i], out var detailType);
+ if (!int.TryParse(form["noteType_" + i], out var noteType) ||
+ !int.TryParse(form["detailType_" + i], out var detailType))
+ {
+ ModelState.AddModelError("Detail", "Invalid note/detail type value.");
+ continue;
+ }Also applies to: 288-289 🤖 Prompt for AI Agents |
||
|
|
||
| var detail = new CustomStateDetail(); | ||
| detail.ButtonText = text; | ||
|
|
@@ -113,15 +113,8 @@ where key.ToString().StartsWith("buttonText_") | |
| detail.DetailType = detailType; | ||
| detail.TextColor = textColor; | ||
|
|
||
| if (!string.IsNullOrWhiteSpace(order)) | ||
| detail.Order = int.Parse(order); | ||
| else | ||
| detail.Order = 0; | ||
|
|
||
| if (!string.IsNullOrWhiteSpace(baseType)) | ||
| detail.BaseType = int.Parse(baseType); | ||
| else | ||
| detail.BaseType = 0; | ||
| detail.Order = int.TryParse(order, out var parsedNewOrder) ? parsedNewOrder : 0; | ||
| detail.BaseType = int.TryParse(baseType, out var parsedNewBaseType) ? parsedNewBaseType : -1; | ||
|
|
||
| model.State.Details.Add(detail); | ||
| } | ||
|
|
@@ -217,6 +210,8 @@ public async Task<IActionResult> EditDetail(EditDetailView model, CancellationTo | |
|
|
||
| model.DetailTypes = model.DetailType.ToSelectList(); | ||
| model.NoteTypes = model.NoteType.ToSelectList(); | ||
| model.BaseTypes = model.BaseType.ToSelectList(); | ||
| model.Detail.CustomState = await _customStateService.GetCustomSateByIdAsync(model.Detail.CustomStateId); | ||
|
|
||
| if (ModelState.IsValid) | ||
| { | ||
|
|
@@ -248,8 +243,6 @@ public async Task<IActionResult> EditDetail(EditDetailView model, CancellationTo | |
| return RedirectToAction("Edit", new { id = detail.CustomStateId }); | ||
| } | ||
|
|
||
| model.Detail.CustomState = await _customStateService.GetCustomSateByIdAsync(model.Detail.CustomStateId); | ||
|
|
||
| return View(model); | ||
| } | ||
|
|
||
|
|
@@ -292,8 +285,8 @@ where key.ToString().StartsWith("buttonText_") | |
| if (gpsValue == "on") | ||
| gps = true; | ||
|
|
||
| var noteType = int.Parse(form["noteType_" + i]); | ||
| var detailType = int.Parse(form["detailType_" + i]); | ||
| int.TryParse(form["noteType_" + i], out var noteType); | ||
| int.TryParse(form["detailType_" + i], out var detailType); | ||
|
|
||
| var detail = new CustomStateDetail(); | ||
| detail.ButtonText = text; | ||
|
|
@@ -302,8 +295,8 @@ where key.ToString().StartsWith("buttonText_") | |
| detail.NoteType = noteType; | ||
| detail.DetailType = detailType; | ||
| detail.TextColor = textColor; | ||
| detail.Order = int.Parse(order); | ||
| detail.BaseType = int.Parse(baseType); | ||
| detail.Order = int.TryParse(order, out var parsedOrder) ? parsedOrder : 0; | ||
| detail.BaseType = int.TryParse(baseType, out var parsedBaseType) ? parsedBaseType : -1; | ||
|
|
||
| if (!string.IsNullOrWhiteSpace(customStateDetailId)) | ||
| detail.CustomStateDetailId = int.Parse(customStateDetailId); | ||
|
|
||
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.
Use the same validated connection for declaration and publish.
This method now validates/declares against one
IConnection, butSendMessagefetches the singleton again afterward. If a reset happens in that gap,_exchangeDeclaredis cleared and publish can still continue on the recreated connection without re-declaring the exchange.Suggested shape
🤖 Prompt for AI Agents