Book Image

Getting Started with Knockout.js for .NET Developers

By : Andrey Ankshin
Book Image

Getting Started with Knockout.js for .NET Developers

By: Andrey Ankshin

Overview of this book

Table of Contents (14 chapters)
Getting Started with Knockout.js for .NET Developers
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Developing a Knockout MVC application


In this section, we will take the HomeLibrary application from the previous chapter and update it with Knockout MVC. We will discuss how this approach can help us simplify an ASP.NET application and allow us to get rid of the client JavaScript code.

Adding the model

We will update the model from the HomeLibrary2 project, as seen in Chapter 3, Integrating Knockout.js in ASP.NET MVC Applications. The BookModel class will "be equal to the version from the old project:

namespace HomeLibrary3.Models
{
  public class BookModel
  {
    public int Id { get; set; }
    public string Title { get; set; }
    public string Author { get; set; }
    public int Year { get; set; }
  }
}

The LibraryModel will be a little easier than its previous version:

using System.Collections.Generic;

namespace HomeLibrary3.Models
{
  public class LibraryModel
  {
    public List<BookModel> Books { get; set; }
    public int NextId { get; set; }
    public string Name { get; set...