using System;
using System.Windows.Forms;

namespace SepehrHotelApiSampleClient.Availability.SearchByCityAndDateAndGuests.WinForms
{
    public partial class RoomUserControl : UserControl
    {
        private RoomAndPassengerCountForm _roomAndPassengerCountForm;
        public class RoomType
        {
            public int SepehrGlobalId { get; set; }

            public string Name { get; set; }
        }

        public RoomUserControl(RoomAndPassengerCountForm roomAndPassengerCountForm)
        {
            _roomAndPassengerCountForm = roomAndPassengerCountForm;
            InitializeComponent();

            SetChildAgeList(cmbChild1Age);
            SetChildAgeList(cmbChild2Age);
            SetChildAgeList(cmbChild3Age);
            SetChildAgeList(cmbChild4Age);
        }

        private void SetChildAgeList(ComboBox comboBox)
        {
            comboBox.Items.Add(new ComboboxItem { Text = "Choose age", Value = -1 });
            comboBox.Items.Add(new ComboboxItem { Text = "0-1", Value = 1 });
            comboBox.Items.Add(new ComboboxItem { Text = "1-2", Value = 2 });
            comboBox.Items.Add(new ComboboxItem { Text = "2-3", Value = 3 });
            comboBox.Items.Add(new ComboboxItem { Text = "3-4", Value = 4 });
            comboBox.Items.Add(new ComboboxItem { Text = "4-5", Value = 5 });
            comboBox.Items.Add(new ComboboxItem { Text = "5-6", Value = 6 });
            comboBox.Items.Add(new ComboboxItem { Text = "6-7", Value = 7 });
            comboBox.Items.Add(new ComboboxItem { Text = "7-8", Value = 8 });
            comboBox.Items.Add(new ComboboxItem { Text = "8-9", Value = 9 });
            comboBox.Items.Add(new ComboboxItem { Text = "9-10", Value = 10 });
            comboBox.Items.Add(new ComboboxItem { Text = "10-11", Value = 11 });
            comboBox.Items.Add(new ComboboxItem { Text = "11-12", Value = 12 });
        }

        public class ComboboxItem
        {
            public string Text { get; set; }
            public short Value { get; set; }
            public byte ValueAsByte => Convert.ToByte(Value);

            public override string ToString()
            {
                return Text;
            }
        }

        private void nudChildCount_ValueChanged(object sender, System.EventArgs e)
        {
            cmbChild1Age.Visible = false;
            cmbChild2Age.Visible = false;
            cmbChild3Age.Visible = false;
            cmbChild4Age.Visible = false;
            _roomAndPassengerCountForm.lblChild1Age.Visible = false;
            _roomAndPassengerCountForm.lblChild2Age.Visible = false;
            _roomAndPassengerCountForm.lblChild3Age.Visible = false;
            _roomAndPassengerCountForm.lblChild4Age.Visible = false;

            if (nudChildCount.Value == 1)
            {
                cmbChild1Age.Visible = true;
                _roomAndPassengerCountForm.lblChild1Age.Visible = true;
            }
            else if (nudChildCount.Value == 2)
            {
                cmbChild1Age.Visible = true;
                cmbChild2Age.Visible = true;
                _roomAndPassengerCountForm.lblChild1Age.Visible = true;
                _roomAndPassengerCountForm.lblChild2Age.Visible = true;
            }
            else if (nudChildCount.Value == 3)
            {
                cmbChild1Age.Visible = true;
                cmbChild2Age.Visible = true;
                cmbChild3Age.Visible = true;
                _roomAndPassengerCountForm.lblChild1Age.Visible = true;
                _roomAndPassengerCountForm.lblChild2Age.Visible = true;
                _roomAndPassengerCountForm.lblChild3Age.Visible = true;
            }
            else if (nudChildCount.Value == 4)
            {
                cmbChild1Age.Visible = true;
                cmbChild2Age.Visible = true;
                cmbChild3Age.Visible = true;
                cmbChild4Age.Visible = true;
                _roomAndPassengerCountForm.lblChild1Age.Visible = true;
                _roomAndPassengerCountForm.lblChild2Age.Visible = true;
                _roomAndPassengerCountForm.lblChild3Age.Visible = true;
                _roomAndPassengerCountForm.lblChild4Age.Visible = true;
            }
        }
    }
}
