using Microsoft.AspNetCore.Components;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using wispro.sp.entity;
using wispro.sp.web.Services;

namespace wispro.sp.web.Components
{
    public partial class PositionSelect
    {
        private List<Position> _allPositions;
        private Position _SelectedItem;

        [Inject] OrganizationService _Service { get; set; }

        [Parameter]
        public int? PositionId { get; set; }


        [Parameter]
        public EventCallback<int?> PositionIdChanged { get; set; }

        protected override async System.Threading.Tasks.Task OnInitializedAsync()
        {
            base.OnInitializedAsync();

            _allPositions = await _Service.getPositions(null);
        }

        private void OnSelectedItemChangedHandler(Position value)
        {
            _SelectedItem = value;
            PositionIdChanged.InvokeAsync(_SelectedItem.Id);
        }
    }
}
