private void btnSave_Click(object sender, EventArgs e) { CategoryBO bo = new CategoryBO(); if (Mode == FormMode.Add) { Category cat = new Category(); cat.CategoryName = txtCatName.Text; cat.Description = txtDescription.Text; cat.Picture = openFileDialog1.FileName; if (bo.Insert(cat)) { MessageBox.Show("Success"); } else { MessageBox.Show("Error"); } } else { SelectedCategory.CategoryName = txtCatName.Text; SelectedCategory.Description = txtDescription.Text; SelectedCategory.Picture = openFileDialog1.FileName; if (bo.Update(SelectedCategory)) { MessageBox.Show("Successfully updated"); } else { MessageBox.Show("There is an error during update operation"); } } }
public IActionResult Put(int id, Category category) { CategoryBO categoryBO; ObjectResult response; try { _log.LogInformation($"Starting Put( {id}, '{JsonConvert.SerializeObject(category, Formatting.None)}')"); categoryBO = new CategoryBO(_loggerFactory, _config); category.ID = id; category = categoryBO.Update(category); response = Ok(category); _log.LogInformation($"Finishing Put( {id} )"); } catch (Exception ex) { _log.LogError(ex.Message); response = StatusCode(500, ex.Message); } return(response); }