Chapter 9: Creating Web Applications with ASP.NET MVC | 279 |
Figure 9-8 The Create screen
Updating Existing Customers
Similar to how we created Customers, you also need two methods for editing a Customer. The get method populates an edit form with existing data, and the post method saves the changes. Listing
Listing 9-11 Methods for editing Customers
C#:
//
// GET: /Customer/Edit/5
public ActionResult Edit(int id)
{
Customer cust =
new CustomerRepository()
.GetCustomer(id);