Esempio n. 1
0
 public ActionResult EditPost()
 {
     service.UpdElement(new ElementBindingModel
     {
         Id          = int.Parse(Request["Id"]),
         ElementName = Request["ElementName"]
     });
     return(RedirectToAction("Index"));
 }
 private void buttonSave_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(textBoxComponent.Text))
     {
         MessageBox.Show("Заполните компонент", "Ошибка", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
         return;
     }
     try
     {
         if (id.HasValue)
         {
             service.UpdElement(new ElementBindingModel
             {
                 Id          = id.Value,
                 ElementName = textBoxComponent.Text
             });
         }
         else
         {
             service.AddElement(new ElementBindingModel
             {
                 ElementName = textBoxComponent.Text
             });
         }
         MessageBox.Show("Сохранение прошло успешно", "Сообщение",
                         MessageBoxButtons.OK, MessageBoxIcon.Information);
         DialogResult = DialogResult.OK;
         Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
 }