Пример #1
0
        private void ExecuteAllocateBus()
        {
            if (AvailableSeats < RequiredSeats)
            {
                return;
            }
            try
            {
                _people.ForEach(x =>
                {
                    if (SelectedRoute == "Makkah to Madinah")
                    {
                        x.MakkahToMadinahBusNumber = SelectedBus.BusNumber;
                    }
                    else if (SelectedRoute == "Makkah to Airport")
                    {
                        x.MakkahToAirportBusNumber = SelectedBus.BusNumber;
                    }
                    if (SelectedRoute == "Madinah to Airport")
                    {
                        x.MadinahToAirportBusNumber = SelectedBus.BusNumber;
                    }
                    if (SelectedRoute == "Madinah To Makkah")
                    {
                        x.MadinahToMakkahBusNumber = SelectedBus.BusNumber;
                    }
                    _repository.PersonRepository.Update(x);
                });
                _repository.Commit();

                var bus = BusDetails.FirstOrDefault(x => x == SelectedBus);
                bus.Capacity -= RequiredSeats;
                if (bus.Capacity == 0)
                {
                    BusDetails.Remove(bus);
                }

                BusDetails = BusDetails.Where(x => true).ToList();
                MessageBox.Show("Alloted bus number", Constants.Success, MessageBoxButton.OK, MessageBoxImage.Information);

                Batches.Remove(SelectedBatch);
                Batches = Batches.Where(x => true).ToList();

                SelectedBus = null;
            }
            catch
            {
                MessageBox.Show("Could not allot bus number", Constants.Success, MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Пример #2
0
        private void RemoveBatches(IEnumerable <Batch> batches)
        {
            if (Batches == null)
            {
                throw SheaftException.NotFound("Cette observation ne contient pas de lots.");
            }

            foreach (var batch in batches)
            {
                var observationBatch = Batches.FirstOrDefault(b => b.BatchId == batch.Id);
                if (observationBatch == null)
                {
                    throw SheaftException.NotFound("Cette observation ne contient pas ce lot.");
                }

                Batches.Remove(observationBatch);
            }
        }