Skip to content

Commit cf93674

Browse files
committed
feat: vincula modelo de dados ao formulário de cadastro
1 parent 403c76e commit cf93674

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System.ComponentModel.DataAnnotations;
2+
3+
namespace BlazingShop.Products.CreateProduct;
4+
5+
public class CreateProductInput
6+
{
7+
[Required(ErrorMessage = "Categoria é obrigatória")]
8+
[Range(1, int.MaxValue, ErrorMessage = "Informe um Id da Categoria maior que 1")]
9+
public int CategoryId { get; set; }
10+
11+
public string Description { get; set; } = string.Empty;
12+
13+
public string Image { get; set; } = string.Empty;
14+
15+
[Required(ErrorMessage = "Preço é obrigatório")]
16+
[DataType(DataType.Currency)]
17+
[Range(0, 9_999.99, ErrorMessage = "Preço deve estar entre 0 e 9.999,00")]
18+
public decimal Price { get; set; }
19+
20+
[Required(ErrorMessage = "Título é obrigatório")]
21+
[MaxLength(150, ErrorMessage = "Título deve ter no máximo 150 caracteres")]
22+
[MinLength(5, ErrorMessage = "Título deve ter no mínimo 5 caracteres")]
23+
public string Title { get; set; } = string.Empty;
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@page "/products/create"
2+
3+
<PageTitle>Create Product</PageTitle>
4+
5+
<h1>New Product</h1>
6+
7+
<EditForm Model="_model">
8+
</EditForm>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace BlazingShop.Products.CreateProduct;
2+
3+
public partial class CreateProductPage
4+
{
5+
private readonly CreateProductInput _model = new();
6+
}

0 commit comments

Comments
 (0)