//Завершение бронирования(покупка)
        public string FinishReserve(int numberOfClient)
        {
            var total = ClientsEntitie.GetAll().DefaultIfEmpty().SingleOrDefault(x => x.CodeClient == numberOfClient);
            if (total != null)
            {
                total.BookOrBuy = true;
                ClientsEntitie.UpdateElement(total);

                Bank tempBank = new Bank();
                tempBank.Ammount = total.Reis.BasicReis.Price;
                tempBank.Date = total.Reis.Date;
                tempBank.Comment = String.Format("Платеж за билет на рейс {0}", total.CodeReis);
                BankEntitie.AddElement(tempBank);
                return String.Format("Продан билет на рейс {0} в {1} на {2}", total.CodeReis, total.Reis.BasicReis.To.Trim(), total.Reis.Date);
            }
            else
            {
                return String.Format("Клиент с таким номером не найден");
            }
        }
        //Покупка
        public string Sell(string destination, DateTime nowTime)
        {
            //Выбираем все рейсы в искомую точку и сортируем по времени
            var basicReises = BasicReisEntitie.GetAll().Where(x => x.To.Trim() == destination.Trim()).Select(x => x.CodeBasicReis);
            var reises = ReisEntitie.GetAll().Where(x => basicReises.Contains((int)x.CodeBasicReis)).OrderBy(x => x.Date);
            //Выбираем из подходящих рейсов, рейсы на которые есть места
            var freeReises = reises.Where(x => PlainsEntitie.GetAll().Single(plain => plain.CodePlane == x.BasicReis.CodePlain).NumberOfSeats - ClientsEntitie.GetAll().Where(client => client.CodeReis == x.CodeReis).Count() > 0);
            //Выбираем первый, по времени, рейс на который есть места
            var total = freeReises.SkipWhile(x => x.Date < nowTime).DefaultIfEmpty(null).First();

            if (total != null)
            {
                Clients tempClient = new Clients();
                tempClient.BookOrBuy = true;
                tempClient.CodeReis = total.CodeReis;
                ClientsEntitie.AddElement(tempClient);

                Bank tempBank = new Bank();
                tempBank.Ammount = total.BasicReis.Price;
                tempBank.Date = total.Date;
                tempBank.Comment = String.Format("Платеж за билет на рейс {0}", total.CodeReis);
                BankEntitie.AddElement(tempBank);
                return String.Format("Продан билет на рейс {0} в {1} на {2}", total.CodeReis, total.BasicReis.To.Trim(), total.Date);
            }
            else
            {
                return String.Format("Билетов в {0} нет на допустимый период", destination);
            }
        }
 partial void UpdateBank(Bank instance);
 partial void DeleteBank(Bank instance);
 partial void InsertBank(Bank instance);