Beispiel #1
0
        private void CreateSite(Site site)
        {
            // create default entities for site
            List <Role> roles = _roleRepository.GetRoles(site.SiteId, true).ToList();

            if (!roles.Where(item => item.Name == Constants.AllUsersRole).Any())
            {
                _roleRepository.AddRole(new Role {
                    SiteId = null, Name = Constants.AllUsersRole, Description = "All Users", IsAutoAssigned = false, IsSystem = true
                });
            }

            if (!roles.Where(item => item.Name == Constants.HostRole).Any())
            {
                _roleRepository.AddRole(new Role {
                    SiteId = null, Name = Constants.HostRole, Description = "Application Administrators", IsAutoAssigned = false, IsSystem = true
                });
            }

            _roleRepository.AddRole(new Role {
                SiteId = site.SiteId, Name = Constants.RegisteredRole, Description = "Registered Users", IsAutoAssigned = true, IsSystem = true
            });
            _roleRepository.AddRole(new Role {
                SiteId = site.SiteId, Name = Constants.AdminRole, Description = "Site Administrators", IsAutoAssigned = false, IsSystem = true
            });

            _profileRepository.AddProfile(new Profile
            {
                SiteId = site.SiteId, Name = "FirstName", Title = "First Name", Description = "Your First Or Given Name", Category = "Name", ViewOrder = 1, MaxLength = 50, DefaultValue = "", IsRequired = true, IsPrivate = false
            });
            _profileRepository.AddProfile(new Profile
            {
                SiteId = site.SiteId, Name = "LastName", Title = "Last Name", Description = "Your Last Or Family Name", Category = "Name", ViewOrder = 2, MaxLength = 50, DefaultValue = "", IsRequired = true, IsPrivate = false
            });
            _profileRepository.AddProfile(new Profile
            {
                SiteId = site.SiteId, Name = "Street", Title = "Street", Description = "Street Or Building Address", Category = "Address", ViewOrder = 3, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false
            });
            _profileRepository.AddProfile(
                new Profile {
                SiteId = site.SiteId, Name = "City", Title = "City", Description = "City", Category = "Address", ViewOrder = 4, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false
            });
            _profileRepository.AddProfile(new Profile
            {
                SiteId = site.SiteId, Name = "Region", Title = "Region", Description = "State Or Province", Category = "Address", ViewOrder = 5, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false
            });
            _profileRepository.AddProfile(new Profile
            {
                SiteId = site.SiteId, Name = "Country", Title = "Country", Description = "Country", Category = "Address", ViewOrder = 6, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false
            });
            _profileRepository.AddProfile(new Profile
            {
                SiteId = site.SiteId, Name = "PostalCode", Title = "Postal Code", Description = "Postal Code Or Zip Code", Category = "Address", ViewOrder = 7, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false
            });
            _profileRepository.AddProfile(new Profile
            {
                SiteId = site.SiteId, Name = "Phone", Title = "Phone Number", Description = "Phone Number", Category = "Contact", ViewOrder = 8, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false
            });

            Folder folder = _folderRepository.AddFolder(new Folder
            {
                SiteId      = site.SiteId, ParentId = null, Name = "Root", Path = "", Order = 1, IsSystem = true,
                Permissions = "[{\"PermissionName\":\"Browse\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"View\",\"Permissions\":\"All Users\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]"
            });

            _folderRepository.AddFolder(new Folder
            {
                SiteId      = site.SiteId, ParentId = folder.FolderId, Name = "Users", Path = Utilities.PathCombine("Users", "\\"), Order = 1, IsSystem = true,
                Permissions = "[{\"PermissionName\":\"Browse\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]"
            });

            // process site template first
            if (string.IsNullOrEmpty(site.SiteTemplateType))
            {
                var section = _config.GetSection("Installation:SiteTemplate");
                if (section.Exists())
                {
                    if (string.IsNullOrEmpty(section.Value))
                    {
                        site.SiteTemplateType = Constants.DefaultSiteTemplate;
                    }
                    else
                    {
                        site.SiteTemplateType = section.Value;
                    }
                }
                else
                {
                    site.SiteTemplateType = Constants.DefaultSiteTemplate;
                }
            }

            Type siteTemplateType = Type.GetType(site.SiteTemplateType);

            if (siteTemplateType != null)
            {
                var siteTemplateObject            = ActivatorUtilities.CreateInstance(_serviceProvider, siteTemplateType);
                List <PageTemplate> pageTemplates = ((ISiteTemplate)siteTemplateObject).CreateSite(site);
                if (pageTemplates != null && pageTemplates.Count > 0)
                {
                    CreatePages(site, pageTemplates);
                }
            }

            // create admin pages
            CreatePages(site, CreateAdminPages());
        }
Beispiel #2
0
 public void AddRole(Role user)
 {
     _roleRepository.AddRole(user);
 }
Beispiel #3
0
        private void CreateSite(Site site)
        {
            List <Role> roles = RoleRepository.GetRoles(site.SiteId, true).ToList();

            if (!roles.Where(item => item.Name == Constants.AllUsersRole).Any())
            {
                RoleRepository.AddRole(new Role {
                    SiteId = null, Name = Constants.AllUsersRole, Description = "All Users", IsAutoAssigned = false, IsSystem = true
                });
            }
            if (!roles.Where(item => item.Name == Constants.HostRole).Any())
            {
                RoleRepository.AddRole(new Role {
                    SiteId = null, Name = Constants.HostRole, Description = "Application Administrators", IsAutoAssigned = false, IsSystem = true
                });
            }

            RoleRepository.AddRole(new Role {
                SiteId = site.SiteId, Name = Constants.RegisteredRole, Description = "Registered Users", IsAutoAssigned = true, IsSystem = true
            });
            RoleRepository.AddRole(new Role {
                SiteId = site.SiteId, Name = Constants.AdminRole, Description = "Site Administrators", IsAutoAssigned = false, IsSystem = true
            });

            ProfileRepository.AddProfile(new Profile {
                SiteId = site.SiteId, Name = "FirstName", Title = "First Name", Description = "Your First Or Given Name", Category = "Name", ViewOrder = 1, MaxLength = 50, DefaultValue = "", IsRequired = true, IsPrivate = false
            });
            ProfileRepository.AddProfile(new Profile {
                SiteId = site.SiteId, Name = "LastName", Title = "Last Name", Description = "Your Last Or Family Name", Category = "Name", ViewOrder = 2, MaxLength = 50, DefaultValue = "", IsRequired = true, IsPrivate = false
            });
            ProfileRepository.AddProfile(new Profile {
                SiteId = site.SiteId, Name = "Street", Title = "Street", Description = "Street Or Building Address", Category = "Address", ViewOrder = 3, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false
            });
            ProfileRepository.AddProfile(new Profile {
                SiteId = site.SiteId, Name = "City", Title = "City", Description = "City", Category = "Address", ViewOrder = 4, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false
            });
            ProfileRepository.AddProfile(new Profile {
                SiteId = site.SiteId, Name = "Region", Title = "Region", Description = "State Or Province", Category = "Address", ViewOrder = 5, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false
            });
            ProfileRepository.AddProfile(new Profile {
                SiteId = site.SiteId, Name = "Country", Title = "Country", Description = "Country", Category = "Address", ViewOrder = 6, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false
            });
            ProfileRepository.AddProfile(new Profile {
                SiteId = site.SiteId, Name = "PostalCode", Title = "Postal Code", Description = "Postal Code Or Zip Code", Category = "Address", ViewOrder = 7, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false
            });
            ProfileRepository.AddProfile(new Profile {
                SiteId = site.SiteId, Name = "Phone", Title = "Phone Number", Description = "Phone Number", Category = "Contact", ViewOrder = 8, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false
            });

            List <ModuleDefinition> moduledefinitions = ModuleDefinitionRepository.GetModuleDefinitions(site.SiteId).ToList();

            foreach (PageTemplate pagetemplate in SiteTemplate)
            {
                int?parentid = null;
                if (pagetemplate.Parent != "")
                {
                    List <Page> pages  = PageRepository.GetPages(site.SiteId).ToList();
                    Page        parent = pages.Where(item => item.Name == pagetemplate.Parent).FirstOrDefault();
                    parentid = parent.PageId;
                }

                Page page = new Page
                {
                    SiteId           = site.SiteId,
                    ParentId         = parentid,
                    Name             = pagetemplate.Name,
                    Path             = pagetemplate.Path,
                    Order            = 1,
                    IsNavigation     = pagetemplate.IsNavigation,
                    EditMode         = pagetemplate.EditMode,
                    ThemeType        = "",
                    LayoutType       = "",
                    Icon             = pagetemplate.Icon,
                    Permissions      = pagetemplate.PagePermissions,
                    IsPersonalizable = pagetemplate.IsPersonalizable,
                    UserId           = null
                };
                page = PageRepository.AddPage(page);

                foreach (PageTemplateModule pagetemplatemodule in pagetemplate.PageTemplateModules)
                {
                    if (pagetemplatemodule.ModuleDefinitionName != "")
                    {
                        ModuleDefinition moduledefinition = moduledefinitions.Where(item => item.ModuleDefinitionName == pagetemplatemodule.ModuleDefinitionName).FirstOrDefault();
                        if (moduledefinition != null)
                        {
                            Module module = new Module
                            {
                                SiteId = site.SiteId,
                                ModuleDefinitionName = pagetemplatemodule.ModuleDefinitionName,
                                Permissions          = pagetemplatemodule.ModulePermissions,
                            };
                            module = ModuleRepository.AddModule(module);

                            if (pagetemplatemodule.Content != "" && moduledefinition.ServerAssemblyName != "")
                            {
                                Assembly assembly = AppDomain.CurrentDomain.GetAssemblies()
                                                    .Where(item => item.FullName.StartsWith(moduledefinition.ServerAssemblyName)).FirstOrDefault();
                                if (assembly != null)
                                {
                                    Type moduletype = assembly.GetTypes()
                                                      .Where(item => item.Namespace != null)
                                                      .Where(item => item.Namespace.StartsWith(moduledefinition.ModuleDefinitionName.Substring(0, moduledefinition.ModuleDefinitionName.IndexOf(","))))
                                                      .Where(item => item.GetInterfaces().Contains(typeof(IPortable))).FirstOrDefault();
                                    if (moduletype != null)
                                    {
                                        var moduleobject = ActivatorUtilities.CreateInstance(ServiceProvider, moduletype);
                                        ((IPortable)moduleobject).ImportModule(module, pagetemplatemodule.Content, moduledefinition.Version);
                                    }
                                }
                            }

                            PageModule pagemodule = new PageModule
                            {
                                PageId        = page.PageId,
                                ModuleId      = module.ModuleId,
                                Title         = pagetemplatemodule.Title,
                                Pane          = pagetemplatemodule.Pane,
                                Order         = 1,
                                ContainerType = ""
                            };
                            PageModuleRepository.AddPageModule(pagemodule);
                        }
                    }
                }
            }
        }
Beispiel #4
0
 public void AddRole(RoleDto role)
 {
     _repository.AddRole(RoleDtoToRoleConvert(role));
 }
Beispiel #5
0
 public async Task <Role> AddRole(Role role)
 {
     return(await _repository.AddRole(role));
 }
        private void CreateSite(Site site)
        {
            RoleRepository.AddRole(new Role {
                SiteId = null, Name = Constants.AllUsersRole, Description = "All Users", IsAutoAssigned = false, IsSystem = true
            });
            RoleRepository.AddRole(new Role {
                SiteId = null, Name = Constants.HostRole, Description = "Application Administrators", IsAutoAssigned = false, IsSystem = true
            });

            RoleRepository.AddRole(new Role {
                SiteId = site.SiteId, Name = Constants.RegisteredRole, Description = "Registered Users", IsAutoAssigned = true, IsSystem = true
            });
            RoleRepository.AddRole(new Role {
                SiteId = site.SiteId, Name = Constants.AdminRole, Description = "Site Administrators", IsAutoAssigned = false, IsSystem = true
            });

            ProfileRepository.AddProfile(new Profile {
                SiteId = site.SiteId, Name = "FirstName", Title = "First Name", Description = "Your First Or Given Name", Category = "Name", ViewOrder = 1, MaxLength = 50, DefaultValue = "", IsRequired = true, IsPrivate = false
            });
            ProfileRepository.AddProfile(new Profile {
                SiteId = site.SiteId, Name = "LastName", Title = "Last Name", Description = "Your Last Or Family Name", Category = "Name", ViewOrder = 2, MaxLength = 50, DefaultValue = "", IsRequired = true, IsPrivate = false
            });
            ProfileRepository.AddProfile(new Profile {
                SiteId = site.SiteId, Name = "Street", Title = "Street", Description = "Street Or Building Address", Category = "Address", ViewOrder = 3, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false
            });
            ProfileRepository.AddProfile(new Profile {
                SiteId = site.SiteId, Name = "City", Title = "City", Description = "City", Category = "Address", ViewOrder = 4, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false
            });
            ProfileRepository.AddProfile(new Profile {
                SiteId = site.SiteId, Name = "Region", Title = "Region", Description = "State Or Province", Category = "Address", ViewOrder = 5, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false
            });
            ProfileRepository.AddProfile(new Profile {
                SiteId = site.SiteId, Name = "Country", Title = "Country", Description = "Country", Category = "Address", ViewOrder = 6, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false
            });
            ProfileRepository.AddProfile(new Profile {
                SiteId = site.SiteId, Name = "PostalCode", Title = "Postal Code", Description = "Postal Code Or Zip Code", Category = "Address", ViewOrder = 7, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false
            });
            ProfileRepository.AddProfile(new Profile {
                SiteId = site.SiteId, Name = "Phone", Title = "Phone Number", Description = "Phone Number", Category = "Contact", ViewOrder = 8, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false
            });

            foreach (PageTemplate pagetemplate in SiteTemplate)
            {
                int?parentid = null;
                if (pagetemplate.Parent != "")
                {
                    List <Page> pages  = PageRepository.GetPages(site.SiteId).ToList();
                    Page        parent = pages.Where(item => item.Name == pagetemplate.Parent).FirstOrDefault();
                    parentid = parent.PageId;
                }

                Page page = new Page
                {
                    SiteId       = site.SiteId,
                    ParentId     = parentid,
                    Name         = pagetemplate.Name,
                    Path         = pagetemplate.Path,
                    Order        = pagetemplate.Order,
                    IsNavigation = pagetemplate.IsNavigation,
                    ThemeType    = site.DefaultThemeType,
                    LayoutType   = site.DefaultLayoutType,
                    Icon         = pagetemplate.Icon,
                    Permissions  = pagetemplate.PagePermissions
                };
                Type type = Type.GetType(page.ThemeType);
                System.Reflection.PropertyInfo property = type.GetProperty("Panes");
                page.Panes = (string)property.GetValue(Activator.CreateInstance(type), null);
                page       = PageRepository.AddPage(page);

                if (pagetemplate.ModuleDefinitionName != "")
                {
                    Module module = new Module
                    {
                        SiteId = site.SiteId,
                        ModuleDefinitionName = pagetemplate.ModuleDefinitionName,
                        Permissions          = pagetemplate.ModulePermissions,
                    };
                    module = ModuleRepository.AddModule(module);

                    PageModule pagemodule = new PageModule
                    {
                        PageId        = page.PageId,
                        ModuleId      = module.ModuleId,
                        Title         = pagetemplate.Title,
                        Pane          = pagetemplate.Pane,
                        Order         = 1,
                        ContainerType = pagetemplate.ContainerType
                    };
                    PageModuleRepository.AddPageModule(pagemodule);
                }
            }
        }
Beispiel #7
0
 public Role PostRole([FromBody] Role role)
 {
     return(_roleRepository.AddRole(role));
 }
 public void AddRole(Role role)
 {
     roleRepository.AddRole(role);
     uow.Commit();
 }