﻿namespace LibrarySystem.App
{
    using System;
    using System.Linq;
    using System.Web.ModelBinding;
    using System.Web.UI;

    using LibrarySystem.App.Models;

    public partial class BookDetails : Page
    {
        private LibraryDbContext dbContext;

        public BookDetails()
        {
            this.dbContext = new LibraryDbContext();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
        }

        public Book FormViewBookDetails_GetItem([QueryString("id")]int? id)
        {
            var book = this.dbContext.Books.FirstOrDefault(b => b.Id == id);
            if (book == null)
            {
                this.Response.Redirect("~/");
            }
            return book;
        }
    }
}