public void InitDateChecker(PlatformApiInfo platformInfo, CityPlatformInfo cityInfo, OperationInfo operationInfo, DelayInfo delayInfo)
        {
            PlatformInfo  = platformInfo;
            CityInfo      = cityInfo;
            OperationInfo = operationInfo;
            DelayInfo     = delayInfo;

            ApiClient = new RestClient(CityInfo.AltApiUrl ?? PlatformInfo.ApiUrl);

            Init();
        }
예제 #2
0
        private void CommonPlatformSelector_SelectedIndexChanged(object sender, EventArgs e)
        {
            PlatformApiInfo platform = PlatformSelector.SelectedItem as PlatformApiInfo;

            ApplyForAll(Reservers, reserver => reserver.SelectPlatform(platform));

            OperationSelector.Items.Clear();

            CitySelector.Items.Clear();
            CitySelector.Items.AddRange((PlatformSelector.SelectedItem as PlatformApiInfo).CityPlatforms);
        }
 public static Dictionary <string, T[]> CreateFromPlatformInfo <T>(
     PlatformApiInfo platform, DelayInfo delayInfo,
     EventHandler <DateCheckerErrorEventArgs> onRequestErrorHandler,
     EventHandler <DateCheckerOkEventArgs> onRequestOkHandler
     ) where T : DateChecker, new()
 {
     return(platform.CityPlatforms.ToDictionary(
                city => city.Name,
                city => CreateFromCityPlatformInfo <T>(
                    platform, city, delayInfo,
                    onRequestErrorHandler,
                    onRequestOkHandler
                    )
                ));
 }
        private void SaveButton_Click(object sender, EventArgs e)
        {
            Order.Surname = SurnameInput.InputText;
            Order.Name    = NameInput.InputText;
            Order.Email   = EmailInput.InputText;

            PlatformApiInfo  selectedPlatform = PlatformSelector.SelectedItem as PlatformApiInfo;
            CityPlatformInfo selectedCity     = CitySelector.SelectedItem as CityPlatformInfo;

            Order.Platform = selectedPlatform.Name;
            Order.City     = selectedCity.Name;
            Order.CityUrl  = selectedCity.BaseUrl;

            Order.Operation = OperationSelector.SelectedItem as OperationInfo;

            this.Close();
        }
        public static T[] CreateFromCityPlatformInfo <T>(
            PlatformApiInfo apiInfo, CityPlatformInfo cityInfo, DelayInfo delayInfo,
            EventHandler <DateCheckerErrorEventArgs> onRequestErrorHandler,
            EventHandler <DateCheckerOkEventArgs> onRequestOkHandler
            ) where T : DateChecker, new()
        {
            T[] checkers = new T[cityInfo.Operations.Length];

            for (int i = 0; i < cityInfo.Operations.Length; ++i)
            {
                checkers[i] = new T();
                checkers[i].InitDateChecker(apiInfo, cityInfo, cityInfo.Operations[i], delayInfo);

                checkers[i].OnRequestError += onRequestErrorHandler;
                checkers[i].OnRequestOK    += onRequestOkHandler;
            }

            return(checkers);
        }
        private ReservationOrder BuildOrder()
        {
            bool surnameInvalid = string.IsNullOrEmpty(SurnameInput.InputText);
            bool nameInvalid    = string.IsNullOrEmpty(NameInput.InputText);
            bool emailInvalid   = string.IsNullOrEmpty(EmailInput.InputText);
            bool typeInvalid    = OperationSelector.SelectedIndex == -1;

            if (surnameInvalid || nameInvalid || emailInvalid || typeInvalid)
            {
                MessageBox.Show("Invalid data");
                return(null);
            }

            PlatformApiInfo  platform  = PlatformSelector.SelectedItem as PlatformApiInfo;
            CityPlatformInfo city      = CitySelector.SelectedItem as CityPlatformInfo;
            OperationInfo    operation = OperationSelector.SelectedItem as OperationInfo;

            ReservationOrder order = new ReservationOrder(
                SurnameInput.InputText, NameInput.InputText, EmailInput.InputText,
                platform.Name, city.Name, city.BaseUrl, operation
                );

            return(order);
        }