using Microsoft.AspNetCore.Components;
using Blazored.Modal;
using Blazored.Modal.Services;
using adminBlazor.Services;
using adminBlazor.Models;

namespace adminBlazor.Modals
{
    public partial class UserDeleteConfirmation
    {
        [CascadingParameter]
        public BlazoredModalInstance ModalInstance { get; set; }

        [Inject]
        public IDataService DataService { get; set; }

        [Parameter]
        public int Id { get; set; }

        private User item = new User();

        protected override async Task OnInitializedAsync()
        {
            // Get the item
            item = await DataService.GetById(Id);
        }

        void ConfirmDelete()
        {
            ModalInstance.CloseAsync(ModalResult.Ok(true));
        }

        void Cancel()
        {
            ModalInstance.CancelAsync();
        }
    }
}