Building the Edit Feature

Now that we have the main structure of the application in place, adding the ability to edit events is straightforward. Listing 31-28 shows the Edit action methods, defined in the EventController class.

Listing 31-28. Implementings the Edit action

using System; using System.Linq; using System.Web.Mvc; using TriathlonApp.Models.Domain; using TriathlonApp.Models.Domain.Repository; using TriathlonApp.Models.View; namespace TriathlonApp.Controllers {     public class EventController : Controller {         private IRepository repository;         ...constructor, Index and Add actions omitted for brevity...         public ActionResult Edit(int id) {             ViewBag.EventTypes = repository.EventTypes.Select(x => x.Name); ...

Get Applied ASP.NET 4 in Context now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.