public FormRestaurants() { InitializeComponent(); _restaurantServiceClient = new RestaurantServiceClient(); _fileServiceClient = new FileServiceClient(); _menuServiceClient = new MenuService.MenuServiceClient(); }
protected void Page_Load(object sender, EventArgs e) { restaurants restaurantList = null; if (Session ["restaurantListSession"] == null) //in case there is no session yet { //opening the xml file string xmlFile = MapPath(@"~/restaurant_reviews.xml"); using (FileStream xs = new FileStream(xmlFile, FileMode.Open)) { //deserializing the file (converting it into an object) XmlSerializer serial = new XmlSerializer(typeof(restaurants)); restaurantList = (restaurants)serial.Deserialize(xs); } Session["restaurantListSession"] = restaurantList; } else { restaurantList = Session["restaurantListSession"] as restaurants; } if (!IsPostBack) //if loading for the first time, display restaurant list using DataBinding: { //code added for lab8: //RestaurantReviewService reviewer = new RestaurantReviewService(); RestaurantServiceClient reviewer = new RestaurantServiceClient(); string[] restaurantNames = reviewer.GetRestaurantNames(); restaurantDropDown.DataSource = restaurantNames; restaurantDropDown.DataBind(); restaurantDropDown.Items.Insert(0, new ListItem("Select One...", "0")); } }
private void button_Click(object sender, RoutedEventArgs e) { var proxyRestaurant = new RestaurantServiceClient(); var res = proxyRestaurant.GetRestaurant(resId); var modelRes = new ModelLibrary.Restaurant { Name = textBoxName.Text, Address = textBoxAddress.Text, Email = textBoxEmail.Text, ZipCode = textBoxZipCode.Text, Category = res.Category, PhoneNo = textBoxPhone.Text, Verified = res.Verified, Discontinued = res.Discontinued, Id = resId }; var validation = ValidateRestaurant(modelRes); if (validation == true) { proxyRestaurant.UpdateRestaurant(modelRes); } else { MessageBox.Show("Validation did not pass"); } }
public RestaurantUpdate(int restaurantId) { InitializeComponent(); resId = restaurantId; var proxyRestaurant = new RestaurantServiceClient(); ModelLibrary.Restaurant res = proxyRestaurant.GetRestaurant(resId); comboBoxCategory.ItemsSource = proxyRestaurant.GetAllRestaurantCategories(); comboBoxCategory.SelectedIndex = 0; if (res != null) { textBoxName.Text = res.Name; textBoxAddress.Text = res.Address; textBoxZipCode.Text = res.ZipCode; textBoxPhone.Text = res.PhoneNo; textBoxEmail.Text = res.Email; textBoxcategory.Text = res.Category.ToString(); checkBoxDiscontinued.IsChecked = res.Discontinued; checkBoxVerified.IsChecked = res.Verified; } else { textBoxName.Text = ""; textBoxAddress.Text = ""; textBoxZipCode.Text = ""; textBoxPhone.Text = ""; textBoxEmail.Text = ""; textBoxcategory.Text = ""; checkBoxDiscontinued.IsChecked = false; checkBoxVerified.IsChecked = false; } }
public async void Init() { using (var svc = new RestaurantServiceClient()) { Restaurants = new BindableCollection<RestaurantDto>(await svc.GetMyRestaurantsAsync(AppData.User.Token)); } }
public static RestaurantServiceClient CreateClient() { Binding binding = new BasicHttpBinding(); var endpoint = new EndpointAddress(new Uri(Application.Current.Host.Source, "../Services/RestaurantService.svc")); var client = new RestaurantServiceClient(binding, endpoint); return client; }
public async void Add() { using (var svc = new RestaurantServiceClient()) { await svc.AddRestaurantAsync(RestaurantName, AppData.User.Token); TryClose(true); } }
public static RestaurantServiceClient CreateClient() { Binding binding = new BasicHttpBinding(); var endpoint = new EndpointAddress(new Uri(Application.Current.Host.Source, "../Services/RestaurantService.svc")); var client = new RestaurantServiceClient(binding, endpoint); return(client); }
public async void Edit() { using (var svc = new RestaurantServiceClient()) { try { await svc.EditRestaurantAsync(_restaurant.Id, RestaurantName, _restaurant.Version, AppData.User.Token); } catch (FaultException<ConcurrencyException> e) { MessageBox.Show("The restaurant has been modified by someone else, your changes has been reverted", "Concurrency error", MessageBoxButton.OK, MessageBoxImage.Warning); } TryClose(true); } }
private void RemoveTable_OnClick(object sender, RoutedEventArgs e) { var proxy = new RestaurantServiceClient(); var table = CreateTable(); if (ValidateTable(table)) { proxy.DeleteTableAsync(table); } else { MessageBoxResult prompt = MessageBox.Show("Please enter valid characters in all fields", "Invalid Input"); } ToTableDataGrid(); }
private void AddTable_OnClick(object sender, RoutedEventArgs e) { var proxy = new RestaurantServiceClient(); var table = new Table { NoSeats = Convert.ToInt32(TextBoxSeatsPerTable.Text), RestaurantId = Convert.ToInt32(HiddenResId.Content.ToString()) }; if (ValidateTable(table)) { proxy.CreateTableAsync(table); ToTableDataGrid(); } else { MessageBoxResult prompt = MessageBox.Show("Please enter valid characters in all fields", "Invalid Input"); } }
private Dictionary <int, int> GetTablesInDictionary() { var proxy = new RestaurantServiceClient(); var call = proxy.GetAllTablesByRestaurantAsync(Convert.ToInt32(HiddenResId.Content.ToString())); var tables = call.Result.ToList(); var dictionary = new Dictionary <int, int>(); foreach (var table in tables) { if (dictionary.ContainsKey(table.NoSeats)) { dictionary[table.NoSeats]++; } else { dictionary.Add(table.NoSeats, 1); } } return(dictionary); }
static void Main(string[] args) { RestaurantServiceClient restaurantClient = new RestaurantServiceClient(); menu[] menus = restaurantClient.getMenus(); order[] order; string grabbedMenuName = ""; bool choosenCorrectly1 = true; while (choosenCorrectly1) { Console.WriteLine("Choose your menu by typing in the name of the menu of your choosing"); foreach (menu currentMenu in menus) { Console.WriteLine(currentMenu.menuName); } string userInput1 = Console.ReadLine(); foreach(menu currentMenu in menus) { if (currentMenu.menuName.Equals(userInput1)) { choosenCorrectly1 = false; grabbedMenuName = userInput1; } } if (choosenCorrectly1) { Console.WriteLine("Incorrect name or format, please follow the instructions :D"); } } order = restaurantClient.getOrders(grabbedMenuName); bool choosenCorrectly2 = true; while (choosenCorrectly2) { Console.WriteLine("Choose an order by typing in the number next to the order"); int orderCount = 1; foreach(order currentOrder in order) { Console.WriteLine(orderCount + ": " + currentOrder.orderName); Console.WriteLine("$" + currentOrder.price); Console.WriteLine(); orderCount++; } try { int userInput2 = int.Parse(Console.ReadLine()); foreach (order currentOrder in order) { if (order.ElementAt(userInput2 - 1).Equals(currentOrder)) { choosenCorrectly2 = false; Console.WriteLine("Order has been sent for " + currentOrder.orderName + " at a price of: $" + currentOrder.price); } } } catch (Exception e) { Console.WriteLine("Incorrect name or format, please follow the instructions :D"); } } Console.ReadLine(); }
public FormMenu() { InitializeComponent(); _menuServices = new MenuService.MenuServiceClient(); _restaurantServiceClient = new RestaurantServiceClient(); }
private IEnumerable <Table> GetTables() { var proxy = new RestaurantServiceClient(); return(proxy.GetAllTablesByRestaurant(Convert.ToInt32(HiddenResId.Content.ToString()))); }
public async void Init() { using (var restaurantSvc = new RestaurantServiceClient()) using (var reservationSvc = new ReservationServiceClient()) { Restaurants = new BindableCollection<RestaurantDto>(await restaurantSvc.GetMyRestaurantsAsync(AppData.User.Token)); Reservations = new BindableCollection<ReservationDto>(await reservationSvc.GetForUserAsync(AppData.User.Token)); } }