@using proevi.Models

<h3>Entry</h3>
<EditForm Model="ProductCategory" OnValidSubmit="OnValidSubmit">
	

	<div class="row">
		
			<input type="hidden" @bind="@ProductCategory.ProductCategoryID" />
			<div>
				<label>Category Name</label>
				<InputText @bind-Value="@ProductCategory.Name" />					
			</div>		
	</div>

	
		<div>
			<h3>
				Add Product

			</h3>
			<div>

				@foreach (var item in ProductCategory.Products)
				{
					<div>
						<div>
							<label>Name</label>						
							<InputText @bind-Value="@item.Name" />													
						</div>
						<div>
							<label>ProductNumber</label>						
							<InputText  @bind-Value="@item.ProductNumber" />													
						</div>

						<div>
							<label>Color</label>					
							<InputText @bind-Value="@item.Color" />														
						</div>
						<div>
							<label>Weight</label>						
							<InputNumber @bind-Value="@item.Weight" />
													
						</div>
						<div>
							<label>Size</label>							
							<InputNumber @bind-Value="@item.Size" />															
						</div>
						<div>
							<label>StandardCost</label>							
							<InputNumber @bind-Value="@item.StandardCost" />														
						</div>
						<div>
							<label>ListPrice</label>					
							<InputNumber  @bind-Value="@item.ListPrice" />
														
						</div>
						<div>
							<button type="button" @onclick="@(() =>
                                ProductCategory.Products.Remove(item))" class="btn-danger">Delete</button>
						</div>
					</div>
				}
				
			</div>
			<div>
				<button type="button" @onclick="AddProduct" class="btn-success">Add</button>
			</div>
		</div>

	<div>
		<div>
			<button type="submit" class="btn-primary">Submit</button>
		</div>
	</div>

</EditForm>

@code {
	[Parameter]
	public ProductCategoryDTO ProductCategory { get; set; }
	[Parameter]
	public EventCallback OnValidSubmit { get; set; }
	public async void AddProduct()
	{
		ProductCategory.Products.Add(new ProductDTO());
	}

}
