示例#1
0
        private void GiveItem()
        {
            Count--;
            db = new TicketsContext();
            db.AirTickets.Load();
            AirTicket ticket = new AirTicket();

            ticket       = db.AirTickets.Find(Id);
            ticket.Count = Count;
            db.SaveChanges();
            db.Dispose();
        }
示例#2
0
        private void AddItem()
        {
            db = new TicketsContext();
            db.AirTickets.Load();
            Random    rand   = new Random();
            AirTicket ticket = new AirTicket();

            ticket.Title = Title;
            ticket.Count = rand.Next(1, 100);
            ticket.Date  = Date;
            ticket.Type  = Type;

            db.AirTickets.Add(ticket);
            db.SaveChanges();
            db.Dispose();
            Console.WriteLine("che nit" + ticket.Title);
        }
示例#3
0
        private void OnStartup(object sender, StartupEventArgs e)
        {
            //List<AirTicket> airTickets = new List<AirTicket>()
            //{
            //new AirTicket(1, "Москва-Минск", "21.05.2018", "Бизнес класс", 5),
            //new AirTicket(2, "Борисполь-Хургада", "13.12.2018", "Эконом класс", 2),
            //new AirTicket(3, "Минск-Лондон", "30.07.2018", "Бизнес класс", 4)
            //};

            db = new TicketsContext();

            db.AirTickets.Load();

            List <AirTicket> airTickets = db.AirTickets.ToList();
            MainWindow       view       = new MainWindow();
            MainViewModel    viewModel  = new MainViewModel(airTickets);

            view.DataContext = viewModel;
            view.Show();
        }