protected virtual bool Authorize(string permissionRecordSystemName, Role userRole)
        {
            if (String.IsNullOrEmpty(permissionRecordSystemName))
                return false;

            foreach (var permission1 in userRole.PermissionRecords)
                if (permission1.SystemName.Equals(permissionRecordSystemName, StringComparison.InvariantCultureIgnoreCase))
                    return true;

            return false;
        }
        public JsonResult CreateOrUpdateRole(string Id, string Name, string Description, string Active)
        {
            try
            {
                int id = Convert.ToInt32(Id);
                if (id == 0)
                {
                    Role newRole = new Role();
                    newRole.Name = Name;
                    newRole.Description = Description;
                    newRole.Active = Convert.ToBoolean(Active);
                    newRole.LastUpdatedOn = DateTime.Now;
                    newRole.CreatedOn = DateTime.Now;
                    newRole.CreatedByUserId = MembershipContext.Current.User.Id;
                    newRole.LastUpdatedByUserId = MembershipContext.Current.User.Id;
                    _unitOfWork.RoleRepository.Insert(newRole);
                    //DebugChangeTracker(id, _unitOfWork, "UpdateRoles", "Role");
                    _unitOfWork.Save();
                    return Json(new { success = true, message = "Role created successfully." });
                }
                else
                {
                    var role = _unitOfWork.RoleRepository.GetSingle(x => x.Id == id);
                    role.Name = Name;
                    role.Description = Description;
                    role.Active = Convert.ToBoolean(Active);
                    role.LastUpdatedOn = DateTime.Now;
                    role.LastUpdatedByUserId = MembershipContext.Current.User.Id;
                    _unitOfWork.RoleRepository.Update(role);
                    _unitOfWork.Save();

                }
                return Json(new { success = true, message = "Role updated successfully." });

            }
            catch (Exception exception)
            {
                Logger.LogException(exception);
                return Json(new { success = false, message = exception.Message });
            }
        }
 public JsonResult GetRole(string id)
 {
     try
     {
         var role = _unitOfWork.RoleRepository.GetById(Convert.ToInt32(id));
         Role editRole = new Role();
         editRole.Id = role.Id;
         editRole.Name = role.Name;
         editRole.Description = role.Description;
         editRole.Active = role.Active;
         return Json(new { success = true, Role = editRole });
     }
     catch (Exception exception)
     {
         Logger.LogException(exception);
         return Json(new { success = false, message = exception.Message });
     }
 }