public CarReview(string carName, int year, string ownerReview, string imageLink, int?ownerID) { InitializeComponent(); this.ownerID = ownerID; OwnerReviewBox.Text = ownerReview; carTitleName.Content = carName; CarYear.Content = year; CarPhoto.Source = new BitmapImage(new Uri(imageLink)); //Owner context = new DatabaseModel(); CarOwner carOwner = context.CarOwners.Find(ownerID); ownerNameTitle.Content = $"{carOwner.FirstName} {carOwner.LastName}"; ownerLocation.Content = carOwner.Location; ownerPhoto.Source = new BitmapImage(new Uri(carOwner.Image)); }
private void MenuItem_Add_Owner_Click(object sender, RoutedEventArgs e) { if (CheckConnection()) { AddNewOwner addOwnerWindow = new AddNewOwner(); CarOwner owner = null; if (addOwnerWindow.ShowDialog() == false) { if (addOwnerWindow.owner != null) { owner = addOwnerWindow.GetOwner; AddOwnerToDB(owner); } } } else { MessageBox.Show("Sorry, seems like it is not possible to connect to DB at the moment"); } }
private void AddOwnerToDB(CarOwner carOwner) { context.CarOwners.Add(carOwner); context.SaveChanges(); }