protected async void Save_Clicked(object sender, EventArgs e) { var newRun = new Run { PersonID = PersonID, DistanceInKM = float.Parse(DistanceInKMCell.Text, CultureInfo.InvariantCulture), TimeInMins = Int32.Parse(TimeInMinsCell.Text), TimeInSeconds = Int32.Parse(TimeInSecondsCell.Text), Terrain = TerrainCell.Text, }; newRun.setPace(); try { using (var runningContext = new RunningContext()) { await runningContext.Runs.AddAsync(newRun); await runningContext.SaveChangesAsync(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } await Navigation.PopModalAsync(); }
async void DeleteAll_Clicked(object sender, EventArgs e) { using (var runningContext = new RunningContext()) { runningContext.RemoveRange(runningContext.People); await runningContext.SaveChangesAsync(); peopleCollectionView.ItemsSource = runningContext.People.ToList(); } }
protected async override void OnAppearing() { peopleCollectionView.SelectedItem = null; using (var runningContext = new RunningContext()) { var thePeople = runningContext.People.ToList(); peopleCollectionView.ItemsSource = thePeople; } }
protected override void OnAppearing() { using (var runningContext = new RunningContext()) { List <Run> runsList = runningContext.Runs .Where(p => p.PersonID == PersonId) .ToList(); runsList.Count(); runsCollection.ItemsSource = runsList; } }
async void Save_Clicked(System.Object sender, System.EventArgs e) { var person = new Person { Name = Name.Text, Age = Int32.Parse(Age.Text), EmailAddress = EmailAddress.Text, Gender = Gender.Text }; using (var runningContext = new RunningContext()) { runningContext.Add(person); await runningContext.SaveChangesAsync(); } await Navigation.PopModalAsync(); }