Beispiel #1
0
        public ActionResult Create([Bind(Include = "EmployeeID,FirstName,LastName,HireDate")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employee));
        }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "ProductID,ProductName,UPC,Price,Inventory")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(product));
        }
Beispiel #3
0
        public ActionResult Create([Bind(Include = "CustomerID,FirstName,LastName,PurchaseDate")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                db.Customers.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customer));
        }
Beispiel #4
0
        public ActionResult Create([Bind(Include = "DepartmentID,DepartmentName")] Department department)
        {
            if (ModelState.IsValid)
            {
                db.Departments.Add(department);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(department));
        }
Beispiel #5
0
        public ActionResult Create([Bind(Include = "PurchaseID,CustomerID,ProductID")] Purchase purchase)
        {
            if (ModelState.IsValid)
            {
                db.Purchases.Add(purchase);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "FirstName", purchase.CustomerID);
            ViewBag.ProductID  = new SelectList(db.Products, "ProductID", "ProductName", purchase.ProductID);
            return(View(purchase));
        }
Beispiel #6
0
        public ActionResult Create([Bind(Include = "AssignmentID,DepartmentID,EmployeeID")] Assignment assignment)
        {
            if (ModelState.IsValid)
            {
                db.Assignments.Add(assignment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "DepartmentName", assignment.DepartmentID);
            ViewBag.EmployeeID   = new SelectList(db.Employees, "EmployeeID", "FirstName", assignment.EmployeeID);
            return(View(assignment));
        }