public JsonResult UpdateCategories([DataSourceRequest] DataSourceRequest request, CategoryAdminViewModel category)
        {
            var existingCategory = this.Data.Categories.Find(category.Id);

            if (existingCategory != null && ModelState.IsValid)
            {
                existingCategory.Name = category.Name;

                this.Data.SaveChanges();
            }

            return Json(new[] { category }.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
        }
        public JsonResult DestroyCategory([DataSourceRequest] DataSourceRequest request, CategoryAdminViewModel category)
        {
            Category categoryFromDb = this.Data.Categories.Find(category.Id);

            foreach (var book in categoryFromDb.Books.ToList())
            {
                this.Data.Books.Remove(book);
            }

            this.Data.Categories.Remove(categoryFromDb);
            this.Data.SaveChanges();

            return Json(new[] { category }.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
        }
        public JsonResult UpdateAuthor([DataSourceRequest] DataSourceRequest request, CategoryAdminViewModel author)
        {
            var existingAuthor = this.Data.Authors.Find(author.Id);

            if (existingAuthor != null && ModelState.IsValid)
            {
                existingAuthor.Name = author.Name;

                this.Data.SaveChanges();
            }

            return Json(new[] { author }.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
        }