public ActionResult CreateSystemSkillCategory([DataSourceRequest] DataSourceRequest request, SystemSkillCategoryVM viewModel, int? SystemRuleId)
        {
            try
            {
                if (viewModel != null && ModelState.IsValid)
                {
                    SystemSkillCategory newviewModel = new SystemSkillCategory();

                    newviewModel = Mapper.Map<SystemSkillCategoryVM, SystemSkillCategory>(viewModel, newviewModel);
                    if (SystemRuleId.HasValue)
                    {
                        newviewModel.SystemRuleSystemRuleId = (int)SystemRuleId;
                        viewModel.SystemRuleSystemRuleId = (int)SystemRuleId;
                    }

                    db.SystemSkillCategories.Add(newviewModel);
                    db.SaveChanges();
                    viewModel.SystemSkillCategoryId = newviewModel.SystemSkillCategoryId;
                    viewModel.SystemRuleSystemName = db.SystemRules.Find(viewModel.SystemRuleSystemRuleId).SystemName;
                }
            }
            catch (DataException dataEx)
            {
                ModelState.AddModelError(string.Empty, "Could not add SystemSkillCategory.");
                Elmah.ErrorSignal.FromCurrentContext().Raise(dataEx);
            }

            return Json(new[] { viewModel }.ToDataSourceResult(request, ModelState));
        }
        public ActionResult UpdateSystemSkillCategory([DataSourceRequest] DataSourceRequest request, SystemSkillCategoryVM viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    SystemSkillCategory newviewModel = new SystemSkillCategory();

                    newviewModel = Mapper.Map<SystemSkillCategoryVM, SystemSkillCategory>(viewModel, newviewModel);

                    db.Entry(newviewModel).State = EntityState.Modified;
                    db.SaveChanges();
                    viewModel.SystemRuleSystemName = db.SystemRules.Find(viewModel.SystemRuleSystemRuleId).SystemName;
                }
            }
            catch (DataException dataEx)
            {
                ModelState.AddModelError(string.Empty, "Could not update SystemSkillCategory.");
                Elmah.ErrorSignal.FromCurrentContext().Raise(dataEx);
            }

            return Json(new[] { viewModel }.ToDataSourceResult(request, ModelState));
        }