/// <summary>
 /// Constructs a ResourceViewModel from a Resource object
 /// </summary>
 /// <param name="resource"></param>
 /// <param name="moduleId">ActiveModuleId</param>
 /// <param name="viewValue">Indica si se desencripta la clave.</param>
 public ResourceViewModel(Resource resource, int moduleId, bool viewValue = false)
 {
     ResourceId = resource.ResourceId;
     ResourceGroupId = resource.ResourceGroupId;
     ResourceGroupName = GroupRepository.Instance.GetGroup(resource.ResourceGroupId).ResourceName;
     ResourceKey = UrlUtils.DecryptParameter(resource.ResourceKey, Common.GetDecryptionKey());
     ResourceValue = viewValue ? (string.IsNullOrEmpty(resource.ResourceValue) ? string.Empty : UrlUtils.DecryptParameter(resource.ResourceValue, Common.GetDecryptionKey())) : resource.ResourceValue;
     Cd = resource.Cd;
     Cu = resource.Cu;
     Md = resource.Md;
     Mu = resource.Mu;
     EditResourceUrl = Components.Common.ResourceEditUrl(moduleId, resource.ResourceGroupId, resource.ResourceId);
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ImportModule implements the IPortable ImportModule Interface.
        /// </summary>
        /// <param name="moduleId">The Id of the module to be imported.</param>
        /// <param name="content">The content to be imported.</param>
        /// <param name="version">The version of the module to be imported.</param>
        /// <param name="userId">The Id of the user performing the import.</param>
        /// -----------------------------------------------------------------------------
        public void ImportModule(int moduleId, string content, string version, int userId)
        {
            var groups = new GroupRepository();
            var xmldnngroups = DotNetNuke.Common.Globals.GetContent(content, "Groups");
            var xmlGroupsNodeList = xmldnngroups.SelectNodes("Group");

            if (xmlGroupsNodeList == null) return;

            foreach (XmlNode xmldnngroup in xmlGroupsNodeList)
            {
                //Import a group
                var resourceGroupId = xmldnngroup.SelectSingleNode("ResourceGroupId");
                var resourceName = xmldnngroup.SelectSingleNode("ResourceName");

                if (resourceGroupId == null || resourceName == null) continue;

                var objdnngroup = new Group
                {
                    ResourceGroupId = new Guid(resourceGroupId.InnerText),
                    ResourceName = resourceName.InnerText,
                };

                groups.ImportCreate(objdnngroup);

                var resources = new ResourceRepository();
                var xmlResourcesNodeList = xmldnngroup.SelectNodes("Resources/Resource");

                //Import the resources of this group
                if (xmlResourcesNodeList == null) return;
                foreach (XmlNode xmldnnresource in xmlResourcesNodeList)
                {
                    var rGroupId = xmldnnresource.SelectSingleNode("ResourceGroupId");
                    var resourceKey = xmldnnresource.SelectSingleNode("ResourceKey");
                    var resourceValue = xmldnnresource.SelectSingleNode("ResourceValue");

                    if (rGroupId == null || resourceKey == null || resourceValue == null) continue;

                    var objdnnresource = new Resource
                    {
                        ResourceGroupId = new Guid(rGroupId.InnerText),
                        ResourceKey = resourceKey.InnerText,
                        ResourceValue = resourceValue.InnerText,

                    };

                    resources.Create(objdnnresource);
                }
            }
        }