private async void Button_Click(object sender, RoutedEventArgs e) { DateTime date = ((DatePicker)CommonHelper.FindChildControl <DatePicker>(this, "EntranceDatePicker")).Date.Date.AddHours(((TimePicker)CommonHelper.FindChildControl <TimePicker>(this, "EntranceTimePicker")).Time.Hours); int people = Int32.Parse(((TextBox)CommonHelper.FindChildControl <TextBox>(this, "NumberOfPeople")).Text); Entrance entrance = new Entrance(date, people, ((Button)sender).Name == "InButton" ? true : false); StatsClient client = new StatsClient(); await client.PostEntrance(entrance); ((Grid)CommonHelper.FindChildControl <Grid>(this, "AddForm")).Visibility = Visibility.Collapsed; ((StackPanel)CommonHelper.FindChildControl <StackPanel>(this, "PostAdd")).Visibility = Visibility.Visible; var entrances = await client.GetEntrances(); this.DefaultViewModel["Entrances"] = entrances; List <EntrancesByDay> entracesPerDay = new List <EntrancesByDay>(); var saturday = await client.GetEntrancesByDay("saturday"); var sunday = await client.GetEntrancesByDay("sunday"); entracesPerDay.Add(new EntrancesByDay("saturday", saturday)); entracesPerDay.Add(new EntrancesByDay("sunday", sunday)); System.Diagnostics.Debug.WriteLine("entracesPerDay"); System.Diagnostics.Debug.WriteLine(entracesPerDay); this.DefaultViewModel["EntrancesPerDay"] = entracesPerDay; this.UpdateLayout(); }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { // TODO: Create an appropriate data model for your problem domain to replace the sample data var sampleDataGroup = await SampleDataSource.GetGroupAsync("Group-4"); this.DefaultViewModel["Section3Items"] = sampleDataGroup; var entrances = await client.GetEntrances(); this.DefaultViewModel["Entrances"] = entrances; List <EntrancesByDay> entracesPerDay = new List <EntrancesByDay>(); var saturday = await client.GetEntrancesByDay("Saturday"); var sunday = await client.GetEntrancesByDay("Sunday"); entracesPerDay.Add(new EntrancesByDay("Tuesday", saturday)); entracesPerDay.Add(new EntrancesByDay("Wednsday", saturday)); entracesPerDay.Add(new EntrancesByDay("Thursday", saturday)); entracesPerDay.Add(new EntrancesByDay("Friday", saturday)); entracesPerDay.Add(new EntrancesByDay("Saturday", saturday)); entracesPerDay.Add(new EntrancesByDay("Sunday", sunday)); System.Diagnostics.Debug.WriteLine("entracesPerDay"); System.Diagnostics.Debug.WriteLine("Saturday " + saturday); System.Diagnostics.Debug.WriteLine(entracesPerDay); this.DefaultViewModel["EntrancesPerDay"] = entracesPerDay; ((TimePicker)CommonHelper.FindChildControl <TimePicker>(this, "EntranceTimePicker")).Time = DateTime.Now.TimeOfDay; }
private async void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { var dayEntrances = await client.GetEntrancesByDay(((TextBlock)((ComboBox)sender).SelectedItem).Name.ToLower()); System.Diagnostics.Debug.WriteLine("elo"); System.Diagnostics.Debug.WriteLine(dayEntrances); System.Diagnostics.Debug.WriteLine(((TextBlock)((ComboBox)sender).SelectedItem).Name.ToLower()); this.DefaultViewModel["DayEntrances"] = dayEntrances; }