public async Task <ActionResult> Create([Bind(Include = "empid,lastname,firstname,title,titleofcourtesy,birthdate,hiredate,address,city,region,postalcode,country,phone,mgrid")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.mgrid = new SelectList(db.Employees, "empid", "lastname", employee.mgrid);
            return(View(employee));
        }
Example #2
0
        public async Task <ActionResult> Create([Bind(Include = "productid,productname,supplierid,categoryid,unitprice,discontinued")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.categoryid = new SelectList(db.Categories, "categoryid", "categoryname", product.categoryid);
            ViewBag.supplierid = new SelectList(db.Suppliers, "supplierid", "companyname", product.supplierid);
            return(View(product));
        }
        public async Task <ActionResult> Create([Bind(Include = "orderid,custid,empid,orderdate,requireddate,shippeddate,shipperid,freight,shipname,shipaddress,shipcity,shipregion,shippostalcode,shipcountry")] Order order)
        {
            if (ModelState.IsValid)
            {
                db.Orders.Add(order);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.empid     = new SelectList(db.Employees, "empid", "lastname", order.empid);
            ViewBag.custid    = new SelectList(db.Customers, "custid", "companyname", order.custid);
            ViewBag.shipperid = new SelectList(db.Shippers, "shipperid", "companyname", order.shipperid);
            return(View(order));
        }