예제 #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> CreateField([FromBody] FieldDTO field)
        {
            if (!ModelState.IsValid || field.Id != 0)
            {
                return(BadRequest(ModelState));
            }

            var create = await _fieldLogic.Create(field);

            field.Id = create;

            return(Ok(create));
            //return CreatedAtAction("GetField", create);
            //return CreatedAtAction("GetField", new {create}, create);
        }