Exemplo n.º 1
0
        public ActionResult AddProduct()
        {
            if (Request.Form["name"] != null)
            {
                product pro = new product
                {
                    name = Request.Form["name"].ToString(),
                    price = Convert.ToDouble(Request.Form["price"].ToString()),
                    currency_id = Convert.ToInt32(Request.Form["currency_id"].ToString())
                };
                db.products.InsertOnSubmit(pro);
                try
                {
                    db.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    // Make some adjustments.
                    // ...
                    // Try again.
                    db.SubmitChanges();
                }
                return RedirectToAction("Index", "Products");
            }

            List<currency> Currencies = new List<currency>();
            Currencies = db.currencies.ToList();
            ViewData["Currencies"] = Currencies;
            return View();
        }
Exemplo n.º 2
0
		private void detach_products(product entity)
		{
			this.SendPropertyChanging();
			entity.currency = null;
		}
Exemplo n.º 3
0
		private void attach_products(product entity)
		{
			this.SendPropertyChanging();
			entity.currency = this;
		}
Exemplo n.º 4
0
 partial void Deleteproduct(product instance);
Exemplo n.º 5
0
 partial void Updateproduct(product instance);
Exemplo n.º 6
0
 partial void Insertproduct(product instance);