// GET:Products/Delete/5 public ActionResult Delete(int id, bool?saveChangesError) { if (saveChangesError.GetValueOrDefault()) { ViewBag.ErrorMessage = "Unable to save changes. Try again, and if the problem persists see your system administrator."; } return(View(ProductMethods.GetItem(id))); }
// GET: Products/Edit/5 public ActionResult Edit(int id) { Product item = ProductMethods.GetItem(id); if (item == null) { return(HttpNotFound()); } return(View(item)); }
/// <summary> /// Поиск и продажа товара /// </summary> /// <param name="product">Товар</param> /// <returns>Логическое значение</returns> public static bool Sales(Product product) { var x = ProductMethods.GetItem(product.Id); if (x != null) { x.Status = false; x.DateOfSale = DateTime.Now; return(ProductMethods.SaveChanges()); } else { return(false); } }
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 GetItem() { productTemp = ProductMethods.GetItem(2); Assert.AreEqual(2, productTemp.Id); }