Skip to content

Commit a7f493f

Browse files
committed
feat: retorna lista de categorias
1 parent d8f4793 commit a7f493f

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
namespace BlazingShop.Products.Common;
22

3-
public sealed class GetCategoriesQuery
4-
{
5-
public int Id { get; }
6-
7-
public string Title { get; } = string.Empty;
8-
}
3+
public sealed record GetCategoriesQuery(int Id, string Title);
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
using BlazingShop.Products.Common;
1+
using BlazingShop.Data;
2+
using BlazingShop.Products.Common;
3+
using Microsoft.EntityFrameworkCore;
24

35
namespace BlazingShop.Products.CreateProduct;
46

5-
public partial class CreateProductPage
7+
public partial class CreateProductPage(AppDbContext context)
68
{
79
private readonly CreateProductInput _model = new();
810

9-
private readonly IEnumerable<GetCategoriesQuery> _categories = [];
11+
private IEnumerable<GetCategoriesQuery> _categories = [];
12+
13+
protected override async Task OnInitializedAsync()
14+
{
15+
_categories = await context.Categories.AsNoTracking()
16+
.Select(c => new GetCategoriesQuery(c.Id, c.Title))
17+
.ToListAsync();
18+
}
1019

1120
async Task HandleSubmitAsync() { }
1221
}

0 commit comments

Comments
 (0)