@using Groceries.Data; @using Microsoft.EntityFrameworkCore; @model Transaction @inject AppDbContext dbContext @{ ViewBag.Title = "New Transaction"; var store = await dbContext.Stores .Where(store => store.Id == Model.StoreId) .Select(store => string.Concat(store.Retailer!.Name, " ", store.Name)) .SingleAsync(); var itemIds = Model.Items.Select(item => item.ItemId); var items = await dbContext.Items .Where(item => itemIds.Contains(item.Id)) .Select(item => new { item.Id, Name = string.Concat(item.Brand, " ", item.Name) }) .ToListAsync(); }

New Transaction

@Model.CreatedAt.ToShortDateString() @Model.CreatedAt.ToLongTimeString() – @store

Items

New item
    @foreach (var item in Model.Items) {
  • @items.Single(i => i.Id == item.ItemId).Name @item.Price.ToString("c") @item.Quantity @((item.Price * item.Quantity).ToString("c")) Edit
  • }
Cancel