private async void btnDelete_Click(object sender, RoutedEventArgs e) { // Delete confirmation if (Selected != null) { ContentDialog notifyDelete = new ContentDialog() { Title = "Confirm delete?", Content = "Are you sure you wish to delete " + Selected.FullName + "?", PrimaryButtonText = "Delete Orphan", SecondaryButtonText = "Cancel" }; ContentDialogResult result = await notifyDelete.ShowAsync(); if (result == ContentDialogResult.Primary) { // Delete OrphanDataService.DeleteOrphan(Selected); // Clear search text box // Can't get to it because it's inside a data template! // Repopulate the list LoadOrphans(); } else { // User pressed Cancel or the back arrow. } } }
private void DisplayOrphanStats() { SfChart chart = new SfChart() { Header = "Orphan Statistics", FontSize = 18, Height = 300, Width = 500 }; OrphanStatistics OrphanStats = new OrphanStatistics(); //GuardianStatistics GuardianStats = new GuardianStatistics(); //NarrationStatistics NarrationStats = new NarrationStatistics(); OrphanStats = OrphanDataService.GetOrphanStatistics(); TotalOrphanCount = OrphanStats.TotalCount; ActiveSeries = new List <ActivePieModel>() { new ActivePieModel { Category = "Active", Value = OrphanStats.ActiveCount }, new ActivePieModel { Category = "Inactive", Value = OrphanStats.InactiveCount }, new ActivePieModel { Category = "Unspecified", Value = OrphanStats.UnknownCount }, //new ActivePieModel { Category = "Total", Value = OrphanStats.TotalCount} }; //Adding Legends for the chart ChartLegend legend = new ChartLegend(); chart.Legend = legend; PieSeries series = new PieSeries() { ItemsSource = ActiveSeries, XBindingPath = "Category", YBindingPath = "Value", ShowTooltip = true, Label = "Values", AdornmentsInfo = new ChartAdornmentInfo() { ShowLabel = true }, }; chart.Series.Add(series); stackOrphanStats.Children.Add(chart); TextBlock txtTotal = new TextBlock(); txtTotal.FontSize = 14; txtTotal.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center; txtTotal.Text = "Total Orphan Count: " + TotalOrphanCount.ToString(); stackOrphanStats.Children.Add(txtTotal); }
private async void btnDelete_Click(object sender, RoutedEventArgs e) { // Delete confirmation if (Selected != null) { ContentDialog notifyDelete = new ContentDialog() { Title = "Confirm Orphan delete?", Content = "Are you sure you wish to delete " + Selected.FullName + "?", PrimaryButtonText = "Delete Orphan", SecondaryButtonText = "Cancel" }; ContentDialogResult result = await notifyDelete.ShowAsync(); if (result == ContentDialogResult.Primary) { if (AppSettings.UseWebApi) { using (var client = new HttpClient()) { var orphanRepo = new OrphanHttpRepository(client); await orphanRepo.DeleteOrphanAsync(Selected.OrphanID); } } else { // Delete OrphanDataService.DeleteOrphan(Selected); } // Clear search text box // Can't get to it because it's inside a data template! // Repopulate the list LoadOrphansAsync(); } else { // User pressed Cancel or the back arrow. } } }
private void btnSave_Click(object sender, RoutedEventArgs e) { Orphan outOrphan = new Orphan(); // Add the save stuff to see if it works. if (!isNew) { outOrphan = InOrphan; } outOrphan.FirstName = txtFirstName.Text; outOrphan.MiddleName = txtMiddleName.Text; outOrphan.LastName = txtLastName.Text; outOrphan.Gender = txtGender.Text; //outOrphan.DateOfBirth = dtDateOfBirth.Date; outOrphan.LCMStatus = txtLCMStatus.Text; //outOrphan.EntryDate = dtEntryDate.Date; if (String.IsNullOrWhiteSpace(txtMiddleName.Text)) { outOrphan.FullName = txtFirstName.Text + " " + txtLastName.Text; } else { outOrphan.FullName = txtFirstName.Text + " " + txtMiddleName.Text + " " + txtLastName.Text; } if (isNew) { // Update to Database OrphanDataService.AddOrphan(outOrphan); } else { // Go get the one of interest, then overwrite. // Update to Database OrphanDataService.SaveOrphan(outOrphan); } // Go Back On_BackRequested(); }
private async void LoadOrphans() { //SampleItems.Clear(); OrphanItems.Clear(); //var data = await SampleDataService.GetMasterDetailDataAsync(); var data = await OrphanDataService.AllOrphans(); foreach (var item in data) { //SampleItems.Add(item); OrphanItems.Add(item); } if (MasterDetailsViewControl.ViewState == MasterDetailsViewState.Both) { //Selected = SampleItems.FirstOrDefault(); Selected = OrphanItems.FirstOrDefault(); } }
private async void btnSave_Click(object sender, RoutedEventArgs e) { Orphan outOrphan = new Orphan(); if (!isNew) { outOrphan = InOrphan; } outOrphan.FirstName = txtFirstName.Text; outOrphan.MiddleName = txtMiddleName.Text; outOrphan.LastName = txtLastName.Text; outOrphan.Gender = txtGender.Text; //outOrphan.DateOfBirth = dtDateOfBirth.Date; outOrphan.LCMStatus = txtLCMStatus.Text; //outOrphan.EntryDate = dtEntryDate.Date; if (String.IsNullOrWhiteSpace(txtMiddleName.Text)) { outOrphan.FullName = txtFirstName.Text + " " + txtLastName.Text; } else { outOrphan.FullName = txtFirstName.Text + " " + txtMiddleName.Text + " " + txtLastName.Text; } if (isNew) { if (AppSettings.UseWebApi) { using (var client = new HttpClient()) { var orphanRepo = new OrphanHttpRepository(client); var orphanCreation = new OrphanCreation { FirstName = outOrphan.FirstName, MiddleName = outOrphan.MiddleName, LastName = outOrphan.LastName, Gender = outOrphan.Gender, DateOfBirth = outOrphan.DateOfBirth, LCMStatus = outOrphan.LCMStatus, ProfileNumber = outOrphan.ProfileNumber }; await orphanRepo.AddOrphanAsync(orphanCreation); } } else { // Update to Database OrphanDataService.AddOrphan(outOrphan); } } else { // Go get the one of interest, then overwrite. if (AppSettings.UseWebApi) { using (var client = new HttpClient()) { var orphanRepo = new OrphanHttpRepository(client); var orphanEdit = new OrphanEdit { FirstName = outOrphan.FirstName, MiddleName = outOrphan.MiddleName, LastName = outOrphan.LastName, Gender = outOrphan.Gender, DateOfBirth = outOrphan.DateOfBirth, LCMStatus = outOrphan.LCMStatus, ProfileNumber = outOrphan.ProfileNumber, EntryDate = outOrphan.EntryDate, GuardianID = outOrphan.GuardianID, ProfilePictureID = outOrphan.ProfilePic.PictureID }; await orphanRepo.UpdateOrphanAsync(outOrphan.OrphanID, orphanEdit); } } else { // Update to Database OrphanDataService.SaveOrphan(outOrphan); } } // Go Back On_BackRequested(); }
private async Task LoadOrphansAsync() { //SampleItems.Clear(); OrphanItems.Clear(); IEnumerable <Orphan> data; // // Use Web API or db directly // if (AppSettings.UseWebApi) { using (HttpClient client = new HttpClient()) { var orphanRepo = new OrphanHttpRepository(client); var parameters = new OrphanParametes { PageNumber = 1, PageSize = 1000 }; var response = await orphanRepo.GetOrphansAsync(parameters); data = response.Orphans.AsEnumerable(); } } else { data = await OrphanDataService.AllOrphans(); using (HttpClient client = new HttpClient()) { var orphanRepo = new PictureHttpRepository(client); var picUrls = await orphanRepo.GetOrphanPicUrls(); foreach (var item in picUrls) { var orphan = data.FirstOrDefault(x => x.OrphanID == item.OrphanID); if (orphan != null) { orphan.ProfilePicUri = item.PicUrl; } } } } //var data = await SampleDataService.GetMasterDetailDataAsync(); //var data = await OrphanDataService.AllOrphans(); foreach (var item in data) { //SampleItems.Add(item); OrphanItems.Add(item); } if (MasterDetailsViewControl.ViewState == MasterDetailsViewState.Both) { Selected = OrphanItems.FirstOrDefault(); LoadNarrationItems(); } }