using Insight.Infrastructure.Services;
using Insight.Web.Constants;
using Microsoft.AspNetCore.Components;

namespace Insight.Web.Pages.Internal;

[Route(Navigation.Internal.Seed)]
public partial class Seed
{
    [Inject] private IdentityService IdentityService { get; init; } = default!;
    [Inject] private ILogger<Seed> Logger { get; init; } = default!;

    private bool IsSuccess = false;

    protected override async Task OnInitializedAsync()
    {
        try
        {
            await IdentityService.SeedAsync();
            IsSuccess = true;
        }
        catch (Exception ex)
        {
            Logger.LogError(ex.ToString());
            IsSuccess = false;
        }
    }
}