protected void Page_Load(object sender, EventArgs e)
        {
            int bookId;

            if (!int.TryParse(this.RouteData.Values["id"].ToString(), out bookId))
            {
                ErrorSuccessNotifier.AddErrorMessage("Missing book id or book id is not a number");
                return;
            }

            Book book = this.data.Books.GetById(bookId);

            if (book == null)
            {
                ErrorSuccessNotifier.AddErrorMessage("Worng book id!");
                return;
            }

            if (book == null)
            {
                BooksLibrarySystem.Web.Controls.ErrorSuccessNotifier.ErrorSuccessNotifier.AddErrorMessage("Worng book id!");
                return;
            }

            this.book = book;
        }
        private int CalcualteRelecance(Book book, string queryString)
        {
            var relevance = 0;
            var words = queryString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            var searchTarget = string.Format("{0}{1}{2}", book.Title, book.Authors, book.Description).ToLower();

            foreach (var word in words)
            {
                if (searchTarget.IndexOf(word.ToLower()) >= 0)
                {
                    relevance ++;
                }
            }

            return relevance;
        }
        public void FormViewBook_InsertItem()
        {
            var book = new Book();
            this.TryUpdateModel(book);

            if (!this.ModelState.IsValid)
            {
                this.SetFormValidity(false);
                this.DisplayErrorMessage();
                return;
            }
            else
            {
                this.SetFormValidity(true);
            }

            this.data.Books.Add(book);
            this.data.SaveChanges();
            this.CloseForm();
            ErrorSuccessNotifier.AddSuccessMessage(MessageBookCreated);
        }