public void AddItems() { List <Product> list = new List <Product>(); Product p = product; Product p1 = p; list.Add(product); list.Add(p); list.Add(p1); Assert.IsTrue(ProductMethods.AddItem(product)); }
// POST: Products/Create public ActionResult Create(Product item) { try { if (ModelState.IsValid) { ProductMethods.AddItem(item); return(RedirectToAction("Index")); } } catch (DataException) { //Log the error (add a variable name after DataException) ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(item)); }
string ProductCommand(string message, string[] json) { Product data = null;; if (json != null) { data = JsonConvert.DeserializeObject <Product>(json[0]); } string outMessage = null; switch (message) { case "AddItem": ProductMethods.AddItem(data); outMessage = "Добавленно"; break; case "AddItems": List <Product> list = new List <Product>(); int i = 0; foreach (var x in json) { Product u = JsonConvert.DeserializeObject <Product>(json[i]); list.Add(u); } ProductMethods.AddItems(list); outMessage = "Добавленно"; break; case "ChangeItem": if (ProductMethods.ChangeItem(data) == true) { outMessage = "Найден"; } else { outMessage = "Не найден"; } break; case "DeleteItem": ProductMethods.DeleteItem(Convert.ToInt32(json[0])); outMessage = "Удален"; break; case "GetItem": string s = JsonConvert.SerializeObject(ProductMethods.GetItem(Convert.ToInt32(json[0]))); outMessage = s; break; case "Outpoot": string outs = null; List <Product> unitWeights = ProductMethods.Outpoot().ToList(); foreach (var x in unitWeights) { outs = $"{outs}!{JsonConvert.SerializeObject(x)}"; } outMessage = outs; break; default: outMessage = "Product connect"; break; } return(outMessage); }
public void AddItem() { Assert.IsTrue(ProductMethods.AddItem(product)); }