public IActionResult Edit(Library model)
        {
            try
            {
                if(!ModelState.IsValid)
                    throw new Exception("De wijzigingen zijn niet");

                var originalModel = _libraryContext.Libraries.FirstOrDefault(m => m.Id == model.Id);

                if(originalModel == null)
                    throw new Exception("De wijzigingen zijn niet");

                originalModel.Name = model.Name;
                originalModel.Code = model.Code;
                originalModel.Description = model.Description;
                originalModel.UpdatedAt = null;

                _libraryContext.Libraries.Attach(originalModel);
                _libraryContext.Entry(originalModel).State = EntityState.Modified;

                int result = _libraryContext.SaveChanges();

                return RedirectToAction("Index");

            }
            catch(Exception ex)
            {
                ModelState.AddModelError(string.Empty, "Unable to save changes.");
            }
            return View(model);
        }
        public IActionResult Create(Library model)
        {
            try
            {
                if(!ModelState.IsValid)
                    throw new Exception("Mislukt");

                _libraryContext.Libraries.Add(model);
                _libraryContext.SaveChanges();

                return RedirectToAction("Index");
            }
            catch(Exception ex)
            {

            }
            return View(model);
        }
        public IActionResult Create(Library model)
        {
            try
            {
                if(!ModelState.IsValid)
                    throw new Exception("The Library model is not valid!");

                _libraryContext.Libraries.Add(model);
                if (_libraryContext.SaveChanges() == 0)
                {
                   throw new Exception("The Library model could not be saved!");
                }

                //Success(CreateMessage(ControllerActionType.Create, "library", model.Name), true);

                return RedirectToAction("Index");
            }
            catch(Exception ex)
            {
                ModelState.AddModelError(string.Empty, "Unable to save changes.");
            }
            return View(model);
        }
        public IActionResult Create()
        {
            var model = new Library();

            return View(model);
        }
        public IActionResult Edit(Library model)
        {
            try
            {
                if(!ModelState.IsValid)
                    throw new Exception("The Library model is not valid!");

                var originalModel = _libraryContext.Libraries.FirstOrDefault(m => m.Id == model.Id);

                if(originalModel == null)
                    throw new Exception("The existing Library: " + model.Name + " doesn't exists anymore!");

                originalModel.Name = model.Name;
                originalModel.Code = model.Code;
                originalModel.Description = model.Description;
                originalModel.UpdatedAt = null;

                _libraryContext.Libraries.Attach(originalModel);
                _libraryContext.Entry(originalModel).State = EntityState.Modified;

                if (_libraryContext.SaveChanges() == 0)
                {
                   throw new Exception("The Library model could not be saved!");
                }

                return RedirectToAction("Index");

            }
            catch(Exception ex)
            {
                ModelState.AddModelError(string.Empty, "Unable to save changes.");
            }
            return View(model);
        }