예제 #1
0
 private void buttonSave_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(textBoxName.Text))
     {
         MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     try
     {
         if (id.HasValue)
         {
             logic.Update(new FieldBindingModel
             {
                 Id   = id.Value,
                 Name = textBoxName.Text
             });
         }
         else
         {
             logic.Create(new FieldBindingModel
             {
                 Name = textBoxName.Text
             });
         }
         MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
         DialogResult = DialogResult.OK;
         Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #2
0
        public async Task <IActionResult> UpdateField([FromBody] FieldDTO field, int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var update = await _fieldLogic.Update(field, id);

            if (update)
            {
                return(NoContent());
            }

            return(NotFound());
        }