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 9-11 shows these two methods.

Listing 9-11 Methods for editing Customers

C#:

//

// GET: /Customer/Edit/5

public ActionResult Edit(int id)

{

Customer cust =

new CustomerRepository()

.GetCustomer(id);

Page 302
Image 302
Microsoft 9GD00001 manual Updating Existing Customers, 279, Listing 9-11 Methods for editing Customers