/// <summary>
 /// Constructs a GroupViewModel from a Group object
 /// </summary>
 /// <param name="group">Resource Group</param>
 /// <param name="moduleId">ActiveModuleId.</param>
 public GroupViewModel(Group group, int moduleId)
 {
     ResourceGroupId = group.ResourceGroupId;
     ResourceName = group.ResourceName;
     PortalId = group.PortalId;
     Cd = group.Cd;
     Cu = group.Cu;
     Md = group.Md;
     Mu = group.Mu;
     EditGroupUrl = Components.Common.GroupEditUrl(moduleId, group.ResourceGroupId);
     AddResourceUrl = Components.Common.ResourceEditUrl(moduleId, group.ResourceGroupId, Guid.Empty);
 }
        /// -----------------------------------------------------------------------------
        /// <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);
                }
            }
        }