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); }