Example #1
0
        public ActionResult Create()
        {
            Product prd = new Product();
            prd.SellEndDate = DateTime.Now;
            prd.SellStartDate = DateTime.Now;
            prd.DiscontinuedDate = DateTime.Now;

            return View(prd);
        }
Example #2
0
        public ActionResult Create(Product prd)
        {
            try {
                if (TryUpdateModel(prd)) {
                    prd.ProductCategoryID = 6;   // hardcode required fields for demo only
                    prd.ProductModelID = 27;
                    prd.ProductNumber = "Test Prod #" + DateTime.Now.Second.ToString();

                    _db.AddToProduct(prd);
                    _db.SaveChanges();

                    return RedirectToAction("Index");
                }
            } catch (Exception ex) {   // For Demo purpose only
                // Production apps should not display exception data.
                ViewData["EditError"] = ex.InnerException;
            }

            return View(prd);
        }