How to design an MVC site

We're going to show here how to design an MVC site using data from a SQL server. The data will be books in my rather large library which consist of 12 bookcases in a small apartment in suburban Los Angeles.

I use Visual Studio 2013.

My original motivation for this was an inventory control application which might be used for a bookstore. In such an application, the end user (the bookstore owner) would probably be interested in information such as quantities of merchandise (e.g., the number of copies of a particular book title), their location in the store (bookcase 38, shelf 2), other particulars which are important for a book such as author(s), cataloguing information such as Dewey Decimal number, Library of Congress call number, and the genre of the book (biography, scientific, fiction, etc.) A bookstore owner would want to know much more such as the sales price of books, the sales history the quantity on hand when books should be re-ordered. But let's keep things simple here. This is a how-to piece and this is my library which frankly would probably make some used book dealers jealous.



Begin in VS2013 by creating a new ASP.Net Web project called BookTitles and press OK.

On the next screen, select the MVC template. Add Unit Tests.

Now, in the Models folder, select Add Class. Name the class BookTitles. The contents of the class are shown below.



using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
namespace BookTitles.Models
{
    public class BookTitles
    {
        [Key]
        public virtual string BookId { get; set; }
        public virtual string BookTitle { get; set; }
        public virtual string Author { get; set; }
        public virtual string Location { get; set; }
        public virtual string LOCCallNumber { get; set; }
        public virtual string DeweyDecCallNumber { get; set; }
        public virtual BookGenre Genre { get; set; }
    }
    public enum BookGenre
    {
        Biography,
        Scientific,
        SoftwareEngineering,
        Mathematics,
        ForeignLanguageInstruction,
        Fiction_EnglishLang,
        Fiction_LangOtherThanEnglish
    }
}