Пример #1
0
        public IActionResult Post([FromBody] PersonViewModel personViewModel)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(Response(personViewModel));
            }

            _personAppService.AddNewPerson(personViewModel);

            return(Response(personViewModel));
        }
Пример #2
0
        private async void btnAddPerson_Click(object sender, System.EventArgs e)
        {
            try
            {
                await _personAppService.AddNewPerson(new AddNewPersonInput
                {
                    Name = txtPersonName.Text
                });

                await LoadAllPeopleAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private async void AddNewPersonButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                await _personAppService.AddNewPerson(new AddNewPersonInput
                {
                    Name = NameTextBox.Text
                });

                await LoadAllPeopleAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }