public JsonResult AddProduct(int catalogId, string name, string description) { var newProduct = new Product(0, catalogId, name, description); var id = m_facade.AddProduct(newProduct); return(Json(new { id }, JsonRequestBehavior.AllowGet)); }
public void Test_Add_Get_Products() { string item1 = "potato"; string item2 = "vegetable"; string item3 = "kg"; string expected1 = "potato"; string expected2 = "vegetable"; string expected3 = "kg"; facade.AddProduct(item1, item2, item3); string actual1 = (facade.GetProducts().Rows[0].ItemArray[0].ToString()); string actual2 = (facade.GetProducts().Rows[0].ItemArray[1].ToString()); string actual3 = (facade.GetProducts().Rows[0].ItemArray[2].ToString()); Assert.AreEqual(expected1, actual1); Assert.AreEqual(expected2, actual2); Assert.AreEqual(expected3, actual3); }
private void buttPodType_Click(object sender, EventArgs e) { facade = new Facade(); try { facade.AddProduct(textBoxP_p.Text, textBoxP_pt.Text, textBoxP_mt.Text); lb_error.Visible = false; } catch (Exception) { lb_error.Visible = true; } if (lb_error.Visible != true) { textBoxP_p.Text = ""; textBoxP_pt.Text = ""; textBoxP_mt.Text = ""; dataGridView3.DataSource = facade.GetProducts(); } }