public JsonResult UpdateCategory([DataSourceRequest] DataSourceRequest request, CategoryAdminViewModel category)
        {
            if (category != null && ModelState.IsValid)
            {
                var existingCategory = this.Data.Categories.GetById(category.Id);
                existingCategory.Name = category.Name;
                this.Data.Categories.Update(existingCategory);
                this.Data.SaveChanges();
            }

            return Json((new[] { category }.ToDataSourceResult(request, ModelState)), JsonRequestBehavior.AllowGet);
        }
        public JsonResult CreateCategory([DataSourceRequest] DataSourceRequest request, CategoryAdminViewModel category)
        {
            if (category != null && ModelState.IsValid)
            {
                Category categoryToBase = new Category()
                {
                    Name = category.Name,
                };

                this.Data.Categories.Add(categoryToBase);
                this.Data.SaveChanges();
                category.Id = categoryToBase.Id;
            }

            return Json(new[] { category }.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet);
        }
        public JsonResult DeleteCategory([DataSourceRequest]DataSourceRequest request, CategoryAdminViewModel category)
        {
            var categoryToDelete = this.Data.Categories.GetById(category.Id);
            if (categoryToDelete != null)
            {
                foreach (var ticket in categoryToDelete.Tickets.ToList())
                {
                    foreach (var comment in ticket.Comments.ToList())
                    {
                        this.Data.Comments.Delete(comment);
                    }

                    this.Data.Tickets.Delete(ticket);
                }

                this.Data.Categories.Delete(categoryToDelete);
                this.Data.SaveChanges();
            }

            return Json(new[] { category }, JsonRequestBehavior.AllowGet);
        }