using Application.Aggregates.Products;
using Application.Aggregates.Products.ViewModels;
using Application.Aggregates.Stores;
using Application.Aggregates.Stores.ViewModels;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace Server.Pages.Panel.Products;

public class CreateModel(ProductsApplication productsApplication) : PageModel
{
    [BindProperty]
    public CreateProductViewModel  createProductView { get; set; }

    public void OnGet()
    {
    }

    public async Task<IActionResult> OnPostAsync()
    {
        if (!ModelState.IsValid)
        {
            return Page();
        }

        await productsApplication.CreateAsync(createProductView);

        return RedirectToPage("Index");
    }
}
