public ActionResult Create([Bind(Include = "CustomerID,CompanyName,ContactName,ContactTitle,Address,City,Region,PostalCode,Country,Phone,Fax")] Customers customers) { if (ModelState.IsValid) { db.Customers.Add(customers); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customers)); }
[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 Create([Bind(Include = "EmployeeID,LastName,FirstName,Title,TitleOfCourtesy,BirthDate,HireDate,Address,City,Region,PostalCode,Country,HomePhone,Extension,Photo,Notes,ReportsTo,PhotoPath")] Employees employees) { if (ModelState.IsValid) { db.Employees.Add(employees); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ReportsTo = new SelectList(db.Employees, "EmployeeID", "LastName", employees.ReportsTo); return(View(employees)); }
public ActionResult Create([Bind(Include = "ProductID,ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued,RPAProcessed,ImageLink")] Products products) { if (ModelState.IsValid) { db.Products.Add(products); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", products.CategoryID); ViewBag.SupplierID = new SelectList(db.Suppliers, "SupplierID", "CompanyName", products.SupplierID); return(View(products)); }
public ActionResult Create([Bind(Include = "OrderID,CustomerID,EmployeeID,OrderDate,RequiredDate,ShippedDate,ShipVia,Freight,ShipName,ShipAddress,ShipCity,ShipRegion,ShipPostalCode,ShipCountry")] Orders orders) { if (ModelState.IsValid) { db.Orders.Add(orders); 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)); }