Exemple #1
0
        private void View_OnLegInstancesUpdateItem(object sender, LegInstancesManagementEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(LegInstancesManagementEventArgs));
            }

            var legInstance = this.legInstancesServices.GetLegInstance(e.Id);

            if (legInstance == null)
            {
                this.View.ModelState.AddModelError(
                    ErrorMessages.MODEL_ERROR_KEY,
                    string.Format(ErrorMessages.MODEL_ERROR_MESSAGE, e.Id));

                return;
            }

            this.View.TryUpdateModel(legInstance);

            if (this.View.ModelState.IsValid)
            {
                legInstance.FlightLegId    = e.FlightLegId;
                legInstance.FlightStatusId = e.FlightStatusId;
                legInstance.AircraftId     = e.AircraftId;

                this.legInstancesServices.UpdateLegInstance(e.Id, legInstance);
            }
        }
Exemple #2
0
        private void View_OnAirportInfoGetItem(object sender, LegInstancesManagementEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(LegInstancesManagementEventArgs));
            }

            this.View.Model.AirportInfo = this.GetAirport(e.AirportId);
        }
Exemple #3
0
        private void View_OnLegInstancesDeleteItem(object sender, LegInstancesManagementEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(LegInstancesManagementEventArgs));
            }

            this.legInstancesServices.DeleteLegInstance(e.Id);
        }
        public void LegInstancesGridView_UpdateItem(int id)
        {
            var legInstanceEventArgs = new LegInstancesManagementEventArgs()
            {
                Id             = id,
                FlightLegId    = int.Parse(this.FlightLegIdHiddenField.Value),
                FlightStatusId = int.Parse(this.FlightStatusIdHiddenField.Value),
                AircraftId     = int.Parse(this.AircraftIdHiddenField.Value)
            };

            this.OnLegInstancesUpdateItem?.Invoke(null, legInstanceEventArgs);
        }
Exemple #5
0
        private void View_OnSendNotificationToSubscribedUsers(object sender, LegInstancesManagementEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(LegInstancesManagementEventArgs));
            }

            var legInstance = this.legInstancesServices.GetLegInstance(e.Id);

            var notificationId            = this.AddNotification(legInstance);
            var usersIdToSendNotification = this.GetSubscribedUsersToReceiveNotification();

            this.userNotificationsServices.SendNotification(notificationId, usersIdToSendNotification);
        }
Exemple #6
0
        private void View_OnLegInstancesAddItem(object sender, LegInstancesManagementEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(LegInstancesManagementEventArgs));
            }

            decimal price = this.faresServices.GetFare(e.FareId).Price;

            var legInstance = new LegInstance()
            {
                DepartureDateTime = e.DepartureDateTime,
                ArrivalDateTime   = e.ArrivalDateTime,
                Price             = price,
                FlightLegId       = e.FlightLegId,
                FlightStatusId    = e.FlightStatusId,
                AircraftId        = e.AircraftId
            };

            e.Id = this.legInstancesServices.AddLegInstance(legInstance);
        }
        protected void CreateLegInstancetBtn_Click(object sender, EventArgs e)
        {
            string seconds = ":00";

            // Convert string to DateTime. The string should look like this: 01/08/2008 14:50:00
            string stringDepartureDateTime = this.LegInstanceDepartureDateTextBox.Text + " " +
                                             this.DepartureTimeTextBox.Text + seconds;

            string stringArrivalDateTime = this.LegInstanceArrivalDateTextBox.Text + " " +
                                           this.ArrivalTimeTextBox.Text + seconds;

            DateTime departureDateTime = Convert.ToDateTime(stringDepartureDateTime);
            DateTime arrivalDateTime   = Convert.ToDateTime(stringArrivalDateTime);

            if (this.AreDateTimesValid(departureDateTime, arrivalDateTime) && this.IsDateTimeAfterDateTimeNow(departureDateTime) &&
                this.IsDateTimeAfterDateTimeNow(departureDateTime) && this.Page.IsValid)
            {
                var legInstanceEventArgs = new LegInstancesManagementEventArgs()
                {
                    DepartureDateTime = departureDateTime,
                    ArrivalDateTime   = arrivalDateTime,
                    FlightLegId       = int.Parse(this.AddFlightLegDropDownList.SelectedItem.Value),
                    FlightStatusId    = int.Parse(this.AddFlightStatusDropDownList.SelectedItem.Value),
                    AircraftId        = int.Parse(this.AddAircraftDropDownList.SelectedItem.Value),
                    FareId            = int.Parse(this.AddFareDropDownList.SelectedItem.Value)
                };

                this.OnLegInstancesAddItem?.Invoke(sender, legInstanceEventArgs);

                this.SuccessPanel.Visible           = true;
                this.AddedLegInstanceIdLiteral.Text = legInstanceEventArgs.Id.ToString();

                this.ClearFields();

                this.OnSendNotificationToSubscribedUsers?.Invoke(null, legInstanceEventArgs);
                this.OnSendMailToSubscribedUsers?.Invoke(null, legInstanceEventArgs);
            }
        }