public void ModificareRestaurant(Restaurant.Restaurant restaurant) { bool succes = false; for (int i = 0; i < restaurante.Count; i++) { if (string.Equals(restaurante[i].getNume(), restaurant.getNume())) { restaurante[i] = restaurant; succes = true; } } if (succes == false) { Console.WriteLine("Nu exista restaurantul"); } }
public void GoToState(Restaurant.Model.States newState) { if (_currentView != null) { MyContainer.Children.Remove(_currentView); _currentView = null; } if (newState == Restaurant.Model.States.Ordering) { _currentView = new OrderingView(); SetButtonColor(Colors.Red, Colors.DarkRed); CreateCircularText(" Confirm Order --- Confirm Order --- Confirm Order ---"); } else if (newState == Restaurant.Model.States.Eating) { _currentView = new EatingView(); SetButtonColor(Colors.Blue, Colors.DarkBlue); CreateCircularText(" Go to Checkout -- Go to Checkout -- Go to Checkout --"); } else if (newState == Restaurant.Model.States.Checkout) { _currentView = new CheckoutView(); SetButtonColor(Colors.Gold, Colors.DarkGoldenrod); CreateCircularText(" Pay Bill ---- Pay Bill --- Pay Bill ---- Pay Bill ---"); } else if (newState == Restaurant.Model.States.Finished) { _currentView = new FinishedView(); //MyContainer.Children.Add(new FinishedView()); //_currentView = null; } if (_currentView != null) { MyContainer.Children.Add(_currentView); } }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; //homepage Get["/cuisines"] = _ => { List <Cuisine> allCuisines = Cuisine.GetAll(); return(View["cuisines.cshtml", allCuisines]); }; //list of all cuisines Get["/restaurants"] = _ => { List <Restaurant> allRestaurants = Restaurant.GetAll(); return(View["restaurants.cshtml", allRestaurants]); }; //list of all restaurants Get["/cuisines/new"] = _ => { return(View["cuisines_form.cshtml"]); }; //navigates to form to add new cuisine Post["/cuisines/new"] = _ => { Cuisine newCuisine = new Cuisine(Request.Form["cuisine-name"]); newCuisine.Save(); List <Cuisine> allCuisines = Cuisine.GetAll(); return(View["cuisines.cshtml", allCuisines]); }; //posts from form adding new cuisine, returns list of all cuisines Get["/restaurants/new"] = _ => { List <Cuisine> AllCuisines = Cuisine.GetAll(); return(View["restaurant_form.cshtml", AllCuisines]); }; //navigates to form to add new restaurant Post["/restaurants/new"] = _ => { Restaurant newRestaurant = new Restaurant(Request.Form["restaurant-name"], Request.Form["restaurant-description"], Request.Form["cuisine-id"]); newRestaurant.Save(); List <Restaurant> allRestaurants = Restaurant.GetAll(); return(View["restaurants.cshtml", allRestaurants]); }; //posts from form adding new restaurant, returns list of all restaurants Get["/restaurant/new/address/{id}"] = parameters => { Restaurant SelectedRestaurant = Restaurant.Find(parameters.id); return(View["address_form.cshtml", SelectedRestaurant]); }; //navigates to form to add address to restaurant Post["/address/new"] = _ => { ContactInfo newContactInfo = new ContactInfo(Request.Form["restaurant-address"], Request.Form["restaurant-phone"], Request.Form["selected-restaurant"]); newContactInfo.Save(); Restaurant ReferenceRestaurant = Restaurant.Find(Request.Form["selected-restaurant"]); List <ContactInfo> RestaurantContactInfo = ReferenceRestaurant.GetContacts(); Dictionary <string, object> model = new Dictionary <string, object>(); model.Add("contacts", RestaurantContactInfo); model.Add("restaurant", ReferenceRestaurant); return(View["restaurant.cshtml", model]); }; //returns individual restaurant page with contact info Post["/cuisines/clear"] = _ => { Cuisine.DeleteAll(); return(View["cuisines.cshtml"]); }; //deletes all cuisines Post["/restaurants/clear"] = _ => { Restaurant.DeleteAll(); return(View["restaurants.cshtml"]); }; //deletes all restaurants Get["/cuisines/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); Cuisine SelectedCuisine = Cuisine.Find(parameters.id); List <Restaurant> CuisineRestaurants = SelectedCuisine.GetRestaurants(); model.Add("cuisine", SelectedCuisine); model.Add("restaurants", CuisineRestaurants); return(View["cuisine.cshtml", model]); }; //retrieves individual cuisine pages Get["/cuisine/edit/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Cuisine SelectedCuisine = Cuisine.Find(parameters.id); string cuisineEdit = Request.Query["cuisine-edit"]; model.Add("form-type", cuisineEdit); model.Add("cuisine", SelectedCuisine); return(View["edit.cshtml", model]); }; //edit individual cuisine Patch["/cuisine/edit/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); Cuisine SelectedCuisine = Cuisine.Find(parameters.id); SelectedCuisine.Update(Request.Form["cuisine-name"]); List <Restaurant> CuisineRestaurants = SelectedCuisine.GetRestaurants(); model.Add("cuisine", SelectedCuisine); model.Add("restaurants", CuisineRestaurants); return(View["cuisine.cshtml", model]); }; //returns edited cuisine page Get["cuisine/delete/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Cuisine SelectedCuisine = Cuisine.Find(parameters.id); string cuisineDelete = Request.Query["cuisine-delete"]; model.Add("form-type", cuisineDelete); model.Add("cuisine", SelectedCuisine); return(View["delete.cshtml", model]); }; //delete individual cuisine Delete["cuisine/delete/{id}"] = parameters => { Cuisine SelectedCuisine = Cuisine.Find(parameters.id); SelectedCuisine.Delete(); List <Cuisine> allCuisines = Cuisine.GetAll(); return(View["cuisines.cshtml", allCuisines]); }; //returns confirmation of deleted cuisine Get["/restaurants/{id}"] = parameters => { Restaurant SelectedRestaurant = Restaurant.Find(parameters.id); List <ContactInfo> RestaurantContactInfo = SelectedRestaurant.GetContacts(); Dictionary <string, object> model = new Dictionary <string, object>(); model.Add("restaurant", SelectedRestaurant); model.Add("contacts", RestaurantContactInfo); return(View["restaurant.cshtml", model]); }; //retrieves individual restaurant pages Get["/restaurant/edit/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Restaurant SelectedRestaurant = Restaurant.Find(parameters.id); string restaurantEdit = Request.Query["restaurant-edit"]; model.Add("form-type", restaurantEdit); model.Add("restaurant", SelectedRestaurant); return(View["edit.cshtml", model]); }; //edit individual restaurants Patch["/restaurant/edit/{id}"] = parameters => { Restaurant SelectedRestaurant = Restaurant.Find(parameters.id); SelectedRestaurant.Update(Request.Form["restaurant-name"], Request.Form["restaurant-description"]); List <ContactInfo> RestaurantContactInfo = SelectedRestaurant.GetContacts(); Dictionary <string, object> model = new Dictionary <string, object>(); model.Add("restaurant", SelectedRestaurant); model.Add("contacts", RestaurantContactInfo); return(View["restaurant.cshtml", model]); }; //returns edited restaurant page Get["restaurant/delete/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object> { }; Restaurant SelectedRestaurant = Restaurant.Find(parameters.id); string restaurantDelete = Request.Query["restaurant-delete"]; model.Add("form-type", restaurantDelete); model.Add("restaurant", SelectedRestaurant); return(View["delete.cshtml", model]); }; //delete individual restaurant Delete["restaurant/delete/{id}"] = parameters => { Restaurant SelectedRestaurant = Restaurant.Find(parameters.id); SelectedRestaurant.Delete(); List <Restaurant> allRestaurants = Restaurant.GetAll(); return(View["restaurants.cshtml", allRestaurants]); }; //returns list of all restaurants }
public void AdaugareRestaurante(Restaurant.Restaurant restaurant) { restaurante.Add(restaurant); }
static void Main(string[] args) { Console.WriteLine("1. Afisare Restaurante"); Console.WriteLine("2. Adaugare Restaurante"); Console.WriteLine("3. Modificare Restaurante"); Console.WriteLine("4. Stergere Restaurante"); Console.WriteLine("0. Exit"); Console.WriteLine("Alegeti Optiunea"); string opt = Console.ReadLine(); RestaurantBL.RestauranteBusinessLogic restaurantebl = new RestaurantBL.RestauranteBusinessLogic(); while (!(string.Equals(opt, "0"))) { if (string.Equals(opt, "1")) { restaurantebl.AfisareRestaurante(); } if (string.Equals(opt, "4")) { string nume = Console.ReadLine(); restaurantebl.StergereRestaurant(nume); } if (string.Equals(opt, "2")) { Console.WriteLine("dati ingredientul"); string ingredient = Console.ReadLine(); Restaurant.Ingredient i = new Restaurant.Ingredient(ingredient); List <Restaurant.Ingredient> ingrediente = new List <Restaurant.Ingredient>(); ingrediente.Add(i); Console.WriteLine("dati pretul"); string pret = Console.ReadLine(); Console.WriteLine("dati numele"); string nume = Console.ReadLine(); Console.WriteLine("dati gramaj"); string gramaj = Console.ReadLine(); Restaurant.Preparate preparat = new Restaurant.Preparate(ingrediente, Convert.ToInt16(pret), nume, Convert.ToInt16(gramaj)); List <Restaurant.Preparate> preparate = new List <Restaurant.Preparate>(); preparate.Add(preparat); Console.WriteLine("dati ora deschidere"); string oraDeschidere = Console.ReadLine(); Console.WriteLine("dati ora inchidere"); string oraInchidere = Console.ReadLine(); Restaurant.Orar orar = new Restaurant.Orar(Convert.ToInt16(oraDeschidere), Convert.ToInt16(oraInchidere)); Console.WriteLine("dati pretul bauturii"); string pretBautura = Console.ReadLine(); Console.WriteLine("dati numele bauturii"); string numeBautura = Console.ReadLine(); Console.WriteLine("dati cantitatea"); string cantitate = Console.ReadLine(); Restaurant.Bautura bautura = new Restaurant.Bautura(Convert.ToInt16(pret), nume, Convert.ToInt16(cantitate)); List <Restaurant.Bautura> bauturi = new List <Restaurant.Bautura>(); bauturi.Add(bautura); Restaurant.Meniu meniu = new Restaurant.Meniu(preparate, bauturi); Console.WriteLine("dati numarul de mese "); string nrMese = Console.ReadLine(); Console.WriteLine("dati adresa"); string adresa = Console.ReadLine(); Console.WriteLine("dati numele restaurantului"); string numeRestaurant = Console.ReadLine(); Restaurant.Restaurant restaurant = new Restaurant.Restaurant(meniu, orar, Convert.ToInt16(nrMese), adresa, numeRestaurant); restaurantebl.AdaugareRestaurante(restaurant); } if (string.Equals(opt, "3")) { Console.WriteLine("dati ingredientul"); string ingredient = Console.ReadLine(); Restaurant.Ingredient i = new Restaurant.Ingredient(ingredient); List <Restaurant.Ingredient> ingrediente = new List <Restaurant.Ingredient>(); ingrediente.Add(i); Console.WriteLine("dati pretul"); string pret = Console.ReadLine(); Console.WriteLine("dati numele"); string nume = Console.ReadLine(); Console.WriteLine("dati gramaj"); string gramaj = Console.ReadLine(); Restaurant.Preparate preparat = new Restaurant.Preparate(ingrediente, Convert.ToInt16(pret), nume, Convert.ToInt16(gramaj)); List <Restaurant.Preparate> preparate = new List <Restaurant.Preparate>(); preparate.Add(preparat); Console.WriteLine("dati ora deschidere"); string oraDeschidere = Console.ReadLine(); Console.WriteLine("dati ora inchidere"); string oraInchidere = Console.ReadLine(); Restaurant.Orar orar = new Restaurant.Orar(Convert.ToInt16(oraDeschidere), Convert.ToInt16(oraInchidere)); Console.WriteLine("dati pretul bauturii"); string pretBautura = Console.ReadLine(); Console.WriteLine("dati numele bauturii"); string numeBautura = Console.ReadLine(); Console.WriteLine("dati cantitatea"); string cantitate = Console.ReadLine(); Restaurant.Bautura bautura = new Restaurant.Bautura(Convert.ToInt16(pret), nume, Convert.ToInt16(cantitate)); List <Restaurant.Bautura> bauturi = new List <Restaurant.Bautura>(); bauturi.Add(bautura); Restaurant.Meniu meniu = new Restaurant.Meniu(preparate, bauturi); Console.WriteLine("dati numarul de mese "); string nrMese = Console.ReadLine(); Console.WriteLine("dati adresa"); string adresa = Console.ReadLine(); Console.WriteLine("dati numele restaurantului"); string numeRestaurant = Console.ReadLine(); Restaurant.Restaurant restaurant = new Restaurant.Restaurant(meniu, orar, Convert.ToInt16(nrMese), adresa, numeRestaurant); restaurantebl.ModificareRestaurant(restaurant); } Console.WriteLine("Dati optiunea"); opt = Console.ReadLine(); } }