Beispiel #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (UnitOfWork db = new UnitOfWork())
     {
         if (City.CityId == 0)
         {
             var model = new repository.City()
             {
                 CityName = txtCityName.Text,
             };
             var result = db.CityServices.AddCity(model);
             if (result.IsChange)
             {
                 db.Save();
                 MessageBox.Show(result.Message);
                 DialogResult = DialogResult.OK;
             }
             else
             {
                 MessageBox.Show(result.Message);
             }
         }
         else
         {
             var model = new repository.City()
             {
                 CityId   = City.CityId,
                 CityName = txtCityName.Text,
             };
             var result = db.CityServices.UpdateCity(model);
             if (result.IsChange)
             {
                 db.Save();
                 MessageBox.Show(result.Message);
                 DialogResult = DialogResult.OK;
             }
             else
             {
                 MessageBox.Show(result.Message);
             }
         }
     }
 }
Beispiel #2
0
 public CreateOrUpdate()
 {
     City = new repository.City();
     InitializeComponent();
 }