public ActionResult Edit([Bind(Include = "accountId,username,password,createtime,lastlogintime,islogon,empolyeeid")] account account) { if (ModelState.IsValid) { db.Entry(account).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(account)); }
[ValidateAntiForgeryToken] //Katso https://go.microsoft.com/fwlink/?LinkId=317598 public ActionResult Edit([Bind(Include = "ShipperID,CompanyName,Phone,RegionID")] Shippers shipper) { if (ModelState.IsValid) { db.Entry(shipper).State = EntityState.Modified; db.SaveChanges(); ViewBag.RegionID = new SelectList(db.Region, "RegionID", "RegionDescription", shipper.RegionID); return(RedirectToAction("Index")); } return(View(shipper)); }
public ActionResult Edit([Bind(Include = "OrderID,CustomerID,EmployeeID,OrderDate,RequiredDate,ShippedDate,ShipVia,Freight,ShipName,ShipAddress,ShipCity,ShipRegion,ShipPostalCode,ShipCountry")] Orders orders) { if (ModelState.IsValid) { db.Entry(orders).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "CompanyName", orders.CustomerID); ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "LastName", orders.EmployeeID); ViewBag.ShipVia = new SelectList(db.Shippers, "ShipperID", "CompanyName", orders.ShipVia); return(View(orders)); }
[ValidateAntiForgeryToken] //Katso https://go.microsoft.com/fwlink/?LinkId=317598 tietoturvaan liittyvä public ActionResult Edit([Bind(Include = "ShipperID,CompanyName,Phone,RegionID")] Shippers shipper) // parametrina tuee Bind(Include = "sarakenimet")] Shippers tyyppinen shipper niminen olio // lomake palauttaa shipperin ja nuo sarakkeet/kentät kaivetaan ja shipper viedään tietokantaan alla olevalla koodilla { if (ModelState.IsValid) // jos ModelStare on validi eli ns. kaikki kunnossa { db.Entry(shipper).State = EntityState.Modified; // using system.data.entity käyttöön, jotta entitystate on tunnistettu // formista tuleva shipper olio tuodaan tähän Entry(shipper). db.Entry pävittää Staten ja sitten tallennetaan muutokset db.SaveChanges(); ViewBag.RegionID = new SelectList(db.Region, "RegionID", "RegionDescription"); // tämä tuli tähän koska RegionID foreignkey lisättiin ja region joinattiin return(RedirectToAction("Index")); } return(View(shipper)); }