All checks were successful
Docker Image CI / build (push) Successful in 3m8s
45 lines
1.5 KiB
Plaintext
45 lines
1.5 KiB
Plaintext
@using Groceries.Data
|
|
@using Microsoft.EntityFrameworkCore
|
|
|
|
@layout Layout
|
|
|
|
@inject IDbContextFactory<AppDbContext> DbContextFactory
|
|
|
|
<PageTitle>Groceries – Edit Transaction Item</PageTitle>
|
|
|
|
<h1>Edit Transaction Item</h1>
|
|
|
|
<div class="form-field">
|
|
@Transaction.CreatedAt.ToShortDateString() @Transaction.CreatedAt.ToLongTimeString() – @store
|
|
</div>
|
|
|
|
<TransactionItemForm TransactionItem="TransactionItem" id="editTransactionItem" />
|
|
|
|
<form method="post" action="/transactions/new/items/delete/@TransactionItem.ItemId" id="deleteTransactionItem" data-action="turbo:submit-end->modal#close"></form>
|
|
|
|
<div class="row">
|
|
<button class="button button--primary" type="submit" form="editTransactionItem">Update</button>
|
|
<a class="button" href="/transactions/new/items">Cancel</a>
|
|
<span class="row__fill"></span>
|
|
<button class="button button--danger" type="submit" form="deleteTransactionItem">Remove</button>
|
|
</div>
|
|
|
|
@code {
|
|
[Parameter]
|
|
public required Transaction Transaction { get; set; }
|
|
|
|
[Parameter]
|
|
public required TransactionItem TransactionItem { get; set; }
|
|
|
|
private string store = string.Empty;
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
using var dbContext = DbContextFactory.CreateDbContext();
|
|
store = await dbContext.Stores
|
|
.Where(store => store.Id == Transaction.StoreId)
|
|
.Select(store => string.Concat(store.Retailer!.Name, " ", store.Name))
|
|
.SingleAsync();
|
|
}
|
|
}
|