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 Post([FromBody] Category category) { CategoryBO categoryBO; ObjectResult response; try { _log.LogInformation($"Starting Post('{JsonConvert.SerializeObject(category, Formatting.None)}')"); categoryBO = new CategoryBO(_loggerFactory, _config); category = categoryBO.Insert(category); response = Ok(category); _log.LogInformation($"Finishing Post"); } catch (Exception ex) { _log.LogError(ex.Message); response = StatusCode(500, ex.Message); } return(response); }
public ActionResult Save(string CategoryName, string Description, string Picture) { Category c = new Category { CategoryName = CategoryName, Description = Description, Picture = Picture }; cbo.Insert(c); return(RedirectToAction("Index", "Category")); }