280Microsoft Visual Studio 2010: A Beginner’s Guide
return View(cust);
}
//
// POST: /Customer/Edit/5
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(Customer cust)
{
try
{
new CustomerRepository()
.UpdateCustomer(cust);
return RedirectToAction("Index");
}
catch
{
return View();
}
}
VB:
'
' GET: /Customer/Edit/5
Function Edit(ByVal id As Integer) As ActionResult Dim custRep As New CustomerRepository
Dim cust As Customer
cust = custRep.GetCustomer(id)
Return View(cust)
End Function
'
' POST: /Customer/Edit/5
<HttpPost()> _
Function Edit(ByVal id As Integer, ByVal cust As Customer) As ActionResult
Try
Dim custRep As New CustomerRepository custRep.UpdateCustomer(cust)