public ActionResult EditPost() { service.UpdElement(new ResourseBindingModel { ResourseId = int.Parse(Request["ResourseId"]), ResourseName = Request["ResourseName"], ResoursePrice = decimal.Parse(Request["ResoursePrice"]) }); return(RedirectToAction("Index")); }
private void buttonSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxName.Text)) { MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrEmpty(textBoxPrice.Text)) { MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { if (id.HasValue) { service.UpdElement(new ResourseBindingModel { Id = id.Value, ResourseName = textBoxName.Text, ResoursePrice = Convert.ToInt32(textBoxPrice.Text), }); } else { service.AddElement(new ResourseBindingModel { ResourseName = textBoxName.Text, ResoursePrice = Convert.ToInt32(textBoxPrice.Text), }); } MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }