public ActionResult Create(Product product) { new ProductRepository().Add(product); return View(); }
/// <summary> /// Remove a Product from the database /// </summary> /// <param name="entity">Product to remove</param> public void Remove(Product product) { Session.Delete(product); }
/// <summary> /// Add a Product to the database /// </summary> /// <param name="entity">Product to add</param> public void Add(Product product) { Session.Save(product); }
/// <summary> /// Add product to the system /// </summary> /// <returns>Result of the add</returns> public JsonResult AddProduct() { try { CategoryRepository categoryRepo = new CategoryRepository(); ProductRepository productRepo = new ProductRepository(); Product product = new Product(); product.Name = Request.Form["Name"]; product.Unit = Request.Form["Unit"]; product.Category = categoryRepo.Get(int.Parse(Request.Form["CategoryId"])); product.Price = Decimal.Parse(Request.Form["Price"]); product.QuantityOnHand = int.Parse(Request.Form["QuantityOnHand"]); product.Counter = 0; product.IsActive = true; productRepo.Add(product); return Json(new { error = false, Name = product.Name, Id = product.Id }); } catch { return Json(new { error = true }); } }