public ActionResult Index(string searchString, bool availability, bool selectedAuthor, bool bookCopyAdded)
        {
            var vm = new BookIndexVm();
            IQueryable <BookDetails> books;

            if (availability || selectedAuthor)
            {
                books = _bookService.GetAvailableBooks().AsQueryable();
                vm.ShowOnlyAvailableCopies = true;
            }
            else
            {
                books = _bookService.GetAllBooks().AsQueryable();
            }

            if (!String.IsNullOrEmpty(searchString))
            {
                vm.Books             = books.Where(b => b.Author.Name.Contains(searchString)).ToList();
                vm.SearchString      = searchString;
                vm.SelectedOnAuthors = true;
            }
            else
            {
                vm.Books = books.ToList();
            }

            // code needed to notify the user of the id of the new bookcopy
            vm.BookCopyAdded = bookCopyAdded ? true : false;
            var listOfBookCopies = _bookCopyService.GetAllBookCopies();
            var lastItem         = listOfBookCopies.Last();

            ViewBag.msg = $"Bookcopy succesfully created. Its ID is: {lastItem.BookCopyId}";

            return(View(vm));
        }
        public ActionResult Create()
        {
            var vm = new LoanCreateVm();

            vm.SelectListBookCopy1 = new SelectList(_bookcopyService.GetAllBookCopies().Where(b => b.IsAvailable == true), "BookCopyId", "BookCopyId");
            vm.SelectListBookCopy2 = new SelectList(_bookcopyService.GetAllBookCopies().Where(b => b.IsAvailable == true), "BookCopyId", "BookCopyId");
            vm.SelectListBookCopy3 = new SelectList(_bookcopyService.GetAllBookCopies().Where(b => b.IsAvailable == true), "BookCopyId", "BookCopyId");

            vm.SelectListMemberId = new SelectList(_memberService.GetAllmembers(), "Id", "Id");

            return(View(vm));
        }