public async Task <ActionResult> Edit([Bind(Include = "empid,lastname,firstname,title,titleofcourtesy,birthdate,hiredate,address,city,region,postalcode,country,phone,mgrid")] Employee employee) { if (ModelState.IsValid) { db.Entry(employee).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.mgrid = new SelectList(db.Employees, "empid", "lastname", employee.mgrid); return(View(employee)); }
public async Task <ActionResult> Edit([Bind(Include = "productid,productname,supplierid,categoryid,unitprice,discontinued")] Product product) { if (ModelState.IsValid) { db.Entry(product).State = EntityState.Modified; 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> Edit([Bind(Include = "orderid,custid,empid,orderdate,requireddate,shippeddate,shipperid,freight,shipname,shipaddress,shipcity,shipregion,shippostalcode,shipcountry")] Order order) { if (ModelState.IsValid) { db.Entry(order).State = EntityState.Modified; 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)); }
public ActionResult Edit([Bind(Include = "OrderID,CustomerID,EmployeeID,OrderDate,RequiredDate,ShippedDate,ShipperID,Freight,ShipName,ShipAddress,ShipCity,ShipRegion,ShipPostalCode,ShipCountry,productName,UnitPrice,Qty")] Orders orders) { if (ModelState.IsValid) { orders.Freight = (string.IsNullOrEmpty(orders.Freight.ToString())) ? 0 : orders.Freight; orders.ShipCountry = (string.IsNullOrEmpty(orders.ShipCountry)) ? string.Empty : orders.ShipCountry; orders.ShipCity = (string.IsNullOrEmpty(orders.ShipCity)) ? string.Empty : orders.ShipCity; orders.ShipRegion = (string.IsNullOrEmpty(orders.ShipRegion)) ? string.Empty : orders.ShipRegion; orders.ShipPostalCode = (string.IsNullOrEmpty(orders.ShipPostalCode)) ? string.Empty : orders.ShipPostalCode; orders.ShipAddress = (string.IsNullOrEmpty(orders.ShipAddress)) ? string.Empty : orders.ShipAddress; orders.ShipName = (string.IsNullOrEmpty(orders.ShipName)) ? string.Empty : orders.ShipName; db.Entry(orders).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "LastName"); ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "CompanyName"); ViewBag.ShipperID = new SelectList(db.Shippers, "ShipperID", "CompanyName"); return(View(orders)); }