Пример #1
0
        // This is the Insert method to insert the entered Product item
        // USAGE: <asp:FormView InsertMethod="InsertItem">
        public void InsertItem()
        {
            using (_db)
            {
                var item = new Samples.Associations.Product();

                TryUpdateModel(item);

                if (ModelState.IsValid)
                {
                    // Save changes
                    _db.Products.Add(item);
                    _db.SaveChanges();

                    Response.Redirect("Default");
                }
            }
        }
Пример #2
0
        // This is the Insert method to insert the entered Product item
        // USAGE: <asp:FormView InsertMethod="InsertItem">
        public void InsertItem()
        {
            using (_db)
            {
                var item = new Samples.Associations.Product();

                TryUpdateModel(item);

                if (ModelState.IsValid)
                {
                    // Save changes
                    _db.Products.Add(item);
                    _db.SaveChanges();

                    Response.Redirect("Default");
                }
            }
        }