public JsonResult GetModules(string UserModeCode)
        {
            ModuleModels mod = new ModuleModels();
            DataTable    dt  = new DataTable();

            dt = mod.GetAvailableModules();
            List <ModuleObject> obj = new List <ModuleObject>();

            //loop the data table and create the module object
            foreach (DataRow dr in dt.Rows)
            {
                bool result   = ModuleModels.checkAccess(UserModeCode, Convert.ToInt32(dr["Id"].ToString()));
                bool hasChild = ModuleModels.hasChild(Convert.ToInt32(dr["Id"].ToString()));
                int  count    = ModuleModels.getChildCount(Convert.ToInt32(dr["Id"].ToString()));
                obj.Add(new ModuleObject
                {
                    Id          = Convert.ToInt32(dr["Id"].ToString()),
                    ParentId    = Convert.ToInt32(dr["ParentId"].ToString()),
                    Name        = dr["Name"].ToString(),
                    Description = dr["Description"].ToString(),
                    IsEnabled   = result,
                    HasChild    = hasChild,
                    ChildCount  = count
                });
            }

            //serialize the object to json
            string json = JsonConvert.SerializeObject(obj);

            //return the json object
            return(Json(json, JsonRequestBehavior.AllowGet));
        }
        public JsonResult CheckRights(string UserModeCode, int ModuleId, int ParentId, string Name)
        {
            Dictionary <string, object> response = new Dictionary <string, object>();

            bool result = ModuleModels.checkAccess(UserModeCode, ModuleId);

            response.Add("Result", result);
            response.Add("ID", ModuleId);
            response.Add("ParentID", ParentId);
            response.Add("Name", Name);

            return(Json(response, JsonRequestBehavior.AllowGet));
        }