public DishPage(Dishes dish, MainWindow w) { InitializeComponent(); Dish = dish; ParentWindow = w; title.Text = Dish.Name; description.Text = Dish.Description; weight.Text = (Math.Round((double)Dish.Weight, 2)).ToString(); rating.Text = (Math.Round((double)Dish.Rating, 2)).ToString(); calories.Text = (Math.Round((double)Dish.Calories, 2)).ToString(); price.Text = (Math.Round((double)Dish.Price, 2)).ToString(); string imageWay = "../../Images/Dishes/" + Dish.Image.Trim() + ".jpg"; dishPageHeader.ImageSource = new BitmapImage(new Uri(imageWay, UriKind.Relative)); using (DeliciousEntities context = new DeliciousEntities()) { List <Restaurants> dishRestaurants = context.Menus.Where(menu => menu.DishId == Dish.Id).Select(menu => menu.Restaurants).ToList(); foreach (Restaurants rest in dishRestaurants) { DishRestaurants.Add(new RestaurantCard(rest, ParentWindow)); } } restContainer.ItemsSource = DishRestaurants; }
public DishCard(Dishes dish, MainWindow w) { InitializeComponent(); ParentWindow = w; CardDish = dish; title.Text = CardDish.Name; descr.Text = CardDish.Description; weight.Text = (Math.Round((double)CardDish.Weight, 2)).ToString(); rating.Text = (Math.Round((double)CardDish.Rating, 2)).ToString(); string imageWay = "../Images/Dishes/" + CardDish.Image.Trim() + ".jpg"; image.Source = new BitmapImage(new Uri(imageWay, UriKind.Relative)); }