Пример #1
0
        public ShowRent(int id)
        {
            RentId = id;
            Rent rent = new Rent();
            User user = new User();
            Car  car  = new Car();

            InitializeComponent();
            using (CarentContext db = new CarentContext())
            {
                rent = db.Rents.Find(id);
                db.Entry(rent).Reference(c => c.Car).Load();
                db.Entry(rent).Reference(c => c.User).Load();
                db.Entry(rent).Reference(c => c.Employee).Load();
                CarTextBlock.Text           += rent.Car.Automaker + " " + rent.Car.Model;
                PriceTextBlock.Text         += rent.TotakPrice;
                UserLoginTextBlock.Text     += rent.User.Login + $"({rent.User.TelephoneNumber})";
                RentStartDateTextBlock.Text += rent.RentalStartDate.ToString("dd.MM.yyy");
                RentEndDateTextBlock.Text   += rent.RentalEndDate.ToString("dd.MM.yyy");
                try
                {
                    EmployeeTextBlock.Text += rent.Employee.FIO;
                }
                catch (Exception e)
                {
                    EmployeeTextBlock.Text += "Нет";
                }
            }
        }
Пример #2
0
        public AdminRents()
        {
            InitializeComponent();

            using (CarentContext db = new CarentContext())
            {
                foreach (Rent r in db.Rents)
                {
                    db.Entry(r).Reference(c => c.Car).Load();
                    db.Entry(r).Reference(c => c.User).Load();
                    db.Entry(r).Reference(c => c.Employee).Load();
                }
                rentsList.ItemsSource = db.Rents.ToList();
            }
        }