public ActionResult EditBarcode(BarcodesEditBarcodeVM model)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            BarcodesRepository barcodesRepository = new BarcodesRepository(context);

            Barcode barcode = null;
            if (barcodesRepository.GetAll().Any(b => b.BarcodeNumber == model.BarcodeNumber) &&
                model.ID != barcodesRepository.GetAll(filter: b => b.BarcodeNumber == model.BarcodeNumber).FirstOrDefault().ID)
            {
                ModelState.AddModelError("BarcodeNumber", "* barcode already exists");
            }
            if (!ModelState.IsValid)
            {
                return View(model);
            }
            else
            {
                if (model.ID > 0)
                {
                    barcode = barcodesRepository.GetByID(model.ID);
                }
                else
                {
                    barcode = new Barcode();
                }

                barcode.ID = model.ID;
                barcode.BookID = model.BookID;
                barcode.BarcodeNumber = model.BarcodeNumber;

                barcodesRepository.Save(barcode);
            }

            return RedirectToAction("ListBookBarcodes/" + barcode.BookID, "Books");
        }
        public ActionResult EditBarcode(int id, int bookID)
        {
            LibraryManagementSystemContext context = new LibraryManagementSystemContext();
            BarcodesRepository barcodesRepository = new BarcodesRepository(context);
            BooksRepository booksRepository = new BooksRepository(context);
            BarcodesEditBarcodeVM model = new BarcodesEditBarcodeVM();

            Barcode barcode = barcodesRepository.GetByID(id);
            if (id > 0)
            {
                if (barcode == null)
                {
                    barcode.BookID = bookID;
                }

                model.ID = barcode.ID;
                model.BookID = barcode.BookID;
                model.BarcodeNumber = barcode.BarcodeNumber;
            }

            return View(model);
        }