using System;
using iElection.Models;
using iElection.Models.Entities;
using iElection.ViewModels;
using Xamarin.Forms;
using SelectionChangedEventArgs = Syncfusion.SfAutoComplete.XForms.SelectionChangedEventArgs;

namespace iElection.Views
{
    public partial class SignUpPage : ContentPage
    {
        public SignUpPage()
        {
            InitializeComponent();
        }

        private void Button_OnClicked(object sender, EventArgs e)
        {

            if (BindingContext is SignUpPageViewModel viewModel)
                viewModel.LoginCommand.Execute(null);
        }

        private void GenderPicker_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            if (sender is Picker picker && picker.SelectedItem is GenderItemModel model && BindingContext is SignUpPageViewModel viewModel)
                viewModel.PageDto.Gender = model.GenderType;

        }

        private void DistrictSfAutoComplete_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {

            if (e.Value is District model && BindingContext is SignUpPageViewModel viewModel)
                viewModel.PageDto.DistrictId = model.Id;
        }

        private void JobSfAutoComplete_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {

            if (e.Value is Job model && BindingContext is SignUpPageViewModel viewModel)
                viewModel.PageDto.JobId = model.Id;
        }
    }
}
