Exemple #1
0
        private async void button3_Click(object sender, EventArgs e)
        {
            var addForm = new AddLocalityForm();

            if (addForm.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            var locality = new Locality()
            {
                Name = addForm.LocalityName
            };

            await LocalityController.AddLocality(locality);

            await FillLocalitesTable();
        }
Exemple #2
0
        private async void button4_Click(object sender, EventArgs e)
        {
            var pk = int.Parse(dataGridView2.SelectedRows[0].Cells[0].Value
                               .ToString());
            var userToUpdate = await Program.Db.Localities.FindAsync(pk);

            var addForm = new AddLocalityForm(userToUpdate);

            if (addForm.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            if (userToUpdate == null)
            {
                return;
            }

            userToUpdate.Name = addForm.LocalityName;

            await Program.Db.SaveChangesAsync();

            await FillLocalitesTable();
        }