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

namespace Server.Pages.Panel.Stores;

public class CreateModel(StoresApplication storesApplication) : PageModel
{
    [BindProperty]
    public CreateStoreViewModel CreateViewModel { get; set; } = new();

    public void OnGet()
    {
    }

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

        await storesApplication.CreateAsync(CreateViewModel);

        return RedirectToPage("Index");
    }
}
