Models


Other than the default model file ErrorViewModel.cs, this project creates a model file Book.cs by performing the folllowing tasks. Select the template :


Add a new class into the Models folder with some properties:




 


C:\ASP.NET-workspace\BookStore1\Models\Book.cs
 using System.ComponentModel.DataAnnotations;

 namespace BookStore1.Models {

   public class Book {

     public int Id { get; set; }

     [ Display( Name = "Book Title" ) ]
     [ Required ]
     public string Title { get; set; }

     public string Genre { get; set; }

     [ DataType( DataType.Currency ) ]
     [ Range( 1, 100 ) ]
     public decimal Price { get; set; }

     [ Display( Name = "Publish Date" ) ]
     [ DataType( DataType.Date ) ]
     public DateTime PublishDate { get; set; }
   }
 }




      “It’s amazing how email has changed our lives.    
      You ever get a handwritten letter in the mail today?    
      ‘What the? Has someone been kidnapped?’”    
      — Jim Gaffigan