private async void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            var    itemselected = (PersonViewModel)Grid.SelectedItem;
            string msg          = "Tem certeza que deseja excluir\n\n";

            msg += $"Nome: {itemselected.FirstName} {itemselected.LastName}\n\n";
            msg += $"Telefone: {itemselected.Phone}";

            var action = MessageBox.Show(msg, "Deletar Registro", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (action == MessageBoxResult.Yes)
            {
                var item = (PersonViewModel)Grid.SelectedItem;

                await PersonHttpClient.Delete(item.Id);

                StartGrid();
            }
        }
Example #2
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var person = new PersonViewModel()
            {
                Id        = _viewModel.Id,
                FirstName = firstName.Text.Trim(),
                LastName  = lastName.Text.Trim(),
                Phone     = phone.Text.Trim()
            };

            var result = await PersonHttpClient.Post(person);

            if (result != null && result.Errors.Messages.Any())
            {
                var listErrors = string.Join("\n\n", result.Errors.Messages);

                MessageBox.Show(listErrors, $"Erro ao tentar {Title}", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            Close();
        }
Example #3
0
 public PersonController(PersonHttpClient personHttpClient)
 {
     _personHttpClient = personHttpClient;
 }
Example #4
0
 public ListModel(PersonHttpClient _personGraphClient)
 {
     personGraphClient = _personGraphClient;
 }
 public async void StartGrid()
 {
     Grid.ItemsSource = await PersonHttpClient.Get();
 }
Example #6
0
 public IndexModel(PersonHttpClient _personHttpClient, PersonGraphClient _personGraphClient)
 {
     personHttpClient  = _personHttpClient;
     personGraphClient = _personGraphClient;
 }