Update card editing to redirect to account details

Modify EditCard page to:
- Accept optional accountId parameter to pre-select account for new cards
- Redirect to AccountDetails page after save (if card has linked account)
- Update navigation to go back to Accounts instead of Cards page

This integrates card management into the account-centric workflow.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
AJ
2025-10-11 22:30:25 -04:00
parent be12d9e53e
commit c409e7ad5b
2 changed files with 18 additions and 4 deletions

View File

@@ -6,7 +6,7 @@
<div class="d-flex justify-content-between align-items-center mb-3">
<h2>@(Model.IsNewCard ? "Add Card" : "Edit Card")</h2>
<a asp-page="/Cards" class="btn btn-outline-secondary">Back to Cards</a>
<a asp-page="/Accounts" class="btn btn-outline-secondary">Back to Accounts</a>
</div>
<div class="row">
@@ -71,7 +71,7 @@
<button type="submit" class="btn btn-primary">
@(Model.IsNewCard ? "Add Card" : "Save Changes")
</button>
<a asp-page="/Cards" class="btn btn-secondary">Cancel</a>
<a asp-page="/Accounts" class="btn btn-secondary">Cancel</a>
</div>
</form>
</div>

View File

@@ -27,7 +27,7 @@ namespace MoneyMap.Pages
[TempData]
public string? SuccessMessage { get; set; }
public async Task<IActionResult> OnGetAsync(int? id)
public async Task<IActionResult> OnGetAsync(int? id, int? accountId)
{
await LoadAvailableAccountsAsync();
@@ -52,6 +52,12 @@ namespace MoneyMap.Pages
else
{
IsNewCard = true;
// Pre-select account if accountId parameter is provided
if (accountId.HasValue)
{
Card.AccountId = accountId.Value;
}
}
return Page();
@@ -98,7 +104,15 @@ namespace MoneyMap.Pages
}
await _db.SaveChangesAsync();
return RedirectToPage("/Cards");
// Redirect back to account details if card is linked to an account
if (Card.AccountId.HasValue)
{
return RedirectToPage("/AccountDetails", new { id = Card.AccountId.Value });
}
// Otherwise redirect to accounts list
return RedirectToPage("/Accounts");
}
private async Task LoadAvailableAccountsAsync()