groceries/Groceries/Transactions/NewTransactionPromotionPage.razor

37 lines
1018 B
Plaintext

@using Groceries.Data
@using Microsoft.EntityFrameworkCore
@layout Layout
@inject AppDbContext DbContext
<PageTitle>Groceries &ndash; New Transaction Promotion</PageTitle>
<h1>New Transaction Promotion</h1>
<div class="form-field">
@Transaction.CreatedAt.ToShortDateString() @Transaction.CreatedAt.ToLongTimeString() &ndash; @store
</div>
<TransactionPromotionForm Transaction="Transaction">
<div class="row">
<button class="button button--primary" type="submit">Add</button>
<a class="button" href="/transactions/new/promotions">Cancel</a>
</div>
</TransactionPromotionForm>
@code {
[Parameter]
public required Transaction Transaction { get; set; }
private string store = string.Empty;
protected override async Task OnParametersSetAsync()
{
store = await DbContext.Stores
.Where(store => store.Id == Transaction.StoreId)
.Select(store => string.Concat(store.Retailer!.Name, " ", store.Name))
.SingleAsync();
}
}