//fills the database if it empty. public void FillDatabase() { if (_restaurantRepository.Read().Count == 0) { var res = new Restaurant { Name = "Bones", Address = "BonesAddres", Describing = "kendt for et spareRibs", Webside = "bones.dk", Foods = new List <Food>() }; var resWithId = _restaurantRepository.Create(res); var food = new Food { Describing = "smagte godt", Name = "SpareRibs", Price = 120, Rating = 3, RestaurantId = resWithId.Id }; _foodRespository.Create(food); res.Foods.Add(food); _restaurantRepository.Update(res); } }
private async void BtnAddRestaurant_OnClicked(object sender, EventArgs e) { if (ResName.Text != null) { Restaurant restaurant = new Restaurant(); restaurant.Name = ResName.Text; restaurant.Address = ResAddress.Text; restaurant.Describing = ResDescribe.Text; restaurant.Webside = ResWebside.Text; restaurant.ImagePath = imagePath; _restaurantRespository.Create(restaurant); await Navigation.PopAsync(); } else { await DisplayAlert("No Name", "Please Enter a Name", "Ok"); } }
private async void BtnAddFood_OnClicked(object sender, EventArgs e) { if (FoodName.Text != null && starRating != null && FoodPrice.Text != null) { Food food = new Food(); food.Name = FoodName.Text; food.Price = Convert.ToSingle(FoodPrice.Text); food.Describing = FoodDescribe.Text; food.Rating = Convert.ToInt32(starRating); food.ImagePath = imagePath; food.RestaurantId = _restaurant.Id; _foodRespository.Create(food); _restaurant.Foods.Add(food); _restaurantRespository.Update(_restaurant); await Navigation.PopAsync(); } else { await DisplayAlert("No Name or no Rating or No Price", "Please Enter a Name, a Price and give a Rating", "Ok"); } }