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:
@@ -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>
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user