Building the Add Event Feature

The user can add a new event to the database by clicking the Add Event button. Before we implement the action method that this button targets, I am going to add some validation and display attributes to the Event model class, as shown in Listing 31-24.

Listing 31-24. Adding display and validation attributes to the Event domain model class

using System; using System.ComponentModel.DataAnnotations; using System.Web.Mvc; namespace TriathlonApp.Models.Domain {     public class Event {         [HiddenInput(DisplayValue=false)]         public int ID { get; set; }         [DataType(DataType.Date)]         public DateTime Date { get; set; }         [Required]         public string Athlete { get; set; }         public ...

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.