Beispiel #1
0
        /// <summary>
        /// CreateAccount
        /// </summary>
        /// <param name="userMembership"></param>
        public void CreateAccount(UserMembership userMembership)
        {
            SiteConfiguration siteConfiguration = eCollabroDbContext.Repository<SiteConfiguration>().Query().Filter(qry => qry.SiteId.Equals(UserContextDetails.SiteId)).Get().FirstOrDefault();
            if (siteConfiguration == null || !siteConfiguration.AllowRegistration)
                throw new BusinessException(_coreValidationResourceManager.GetString(CoreValidationMessagesConstants.SiteRegistrationNotAllowed), CoreValidationMessagesConstants.SiteRegistrationNotAllowed);

            UserMembership existingUser = eCollabroDbContext.Repository<UserMembership>().Query().Filter(qry => qry.UserName.Equals(userMembership.UserName) || qry.Email.Equals(userMembership.Email)).Get().FirstOrDefault();
            if (existingUser != null) //user by user name or email already exist
            {
                throw new BusinessException(_coreValidationResourceManager.GetString(CoreValidationMessagesConstants.UserAlreadyExist), CoreValidationMessagesConstants.UserAlreadyExist);
            }
            else
            {
                KeyValuePair<string, string> pass = DataEncryption.CreateHashedText(DataEncryption.Decrypt(userMembership.Password), true);

                List<SiteContentSettingResult> siteContentSettingResults = GetSiteFeatureSettings(FeatureEnum.User);
                bool approvalRequired = siteContentSettingResults.Where(qry => qry.ContentSettingId.Equals((int)FeatureSettingEnum.ApprovalRequired)).FirstOrDefault().IsAssigned;

                UserRole userRole = new UserRole();
                userRole.SiteId = UserContextDetails.SiteId;
                userRole.RoleId = siteConfiguration.RegistrationDefaultRoleId.Value;
                userRole.CreatedOn = DateTime.UtcNow;
                userMembership.CreatedOn = DateTime.UtcNow;
                userMembership.UserRoles.Add(userRole);
                userMembership.Password = pass.Key;
                userMembership.PasswordSalt = pass.Value;
                if(siteConfiguration.AccountRequireEmailVerification)
                {
                    userMembership.IsConfirmed = false;
                    userMembership.ConfirmationToken=RandomGenerator.RandomString(10);
                }
                else
                {
                    userMembership.IsConfirmed=true;
                }
                userMembership.IsApproved=!approvalRequired;
                userMembership.IsActive = true;
                eCollabroDbContext.Repository<UserMembership>().Insert(userMembership);

                eCollabroDbContext.Save();

                if (siteConfiguration.AccountRequireEmailVerification)// send verification email
                {
                    var verificationLink = "<a href='/account/verifyaccount/?uname=" + userMembership.UserName + "&token=" + userMembership.ConfirmationToken + "'>Verify Account</a>";
                    string subject = "Verify Account";
                    string body = string.Format("Dear {0} <br/> Click link below to Verify your account.<br/>{1}", userMembership.UserName, verificationLink);
                    MailMessage message = new MailMessage("*****@*****.**", userMembership.Email, subject, body);
                    _commonManager.SendEmail(message);
                }

            }
        }
Beispiel #2
0
        /// <summary>
        /// ResetUserPassword
        /// </summary>
        /// <param name="userMembership"></param>
        /// <returns></returns>
        private string ResetUserPassword(UserMembership userMembership)
        {
            string password = RandomGenerator.RandomString(8);
            KeyValuePair<string, string> pass = DataEncryption.CreateHashedText(password, true);
            userMembership.Password = pass.Key;
            userMembership.PasswordSalt = pass.Value;
            userMembership.PasswordVerificationToken = string.Empty;
            userMembership.IsLocked = false;
            userMembership.PasswordFailuresSinceLastSuccess = 0;
            eCollabroDbContext.Save();

            //Create email
            string subject = "Password has been reset";
            string body = string.Format("Your password has been reset to {0}", password);
            MailMessage message = new MailMessage("*****@*****.**", userMembership.Email, subject, body);
            _commonManager.SendEmail(message);
            return DataEncryption.Encrypt(password);
        }
Beispiel #3
0
 /// <summary>
 /// eCollabroSetup
 /// </summary>
 /// <param name="serviceRequest"></param>
 /// <returns></returns>
 public ServiceResponse eCollabroSetup(RegisterDC register)
 {
     ServiceResponse eCollabroSetupResponse = new ServiceResponse();
     try
     {
         UserMembership userMembership = new UserMembership();
         userMembership.UserName = register.UserName;
         userMembership.Password = register.Password;
         userMembership.Email = register.Email;
         _setupManager.SetupEcollabro(userMembership);
     }
     catch (Exception ex)
     {
         HandleError(ex, eCollabroSetupResponse);
     }
     return eCollabroSetupResponse;
 }
Beispiel #4
0
        /// <summary>
        /// SaveUser
        /// </summary>
        /// <param name="userMember"></param>
        /// <param name="userProfile"></param>
        /// <param name="userRole"></param>
        public void SaveUser(UserMembership userMember)
        {
            #region Check Permission

            List<PermissionEnum> userPermissions = GetUserFeaturePermissions(UserContextDetails.UserId, FeatureEnum.User);
            if ((userMember.UserId.Equals(0) && !userPermissions.Contains(PermissionEnum.AddContent)) || (!userMember.UserId.Equals(0) && !userPermissions.Contains(PermissionEnum.EditContent)))
                throw new BusinessException(_coreValidationResourceManager.GetString(CoreValidationMessagesConstants.UnAuthorized), CoreValidationMessagesConstants.UnAuthorized);

            #endregion

            if (userMember.UserId.Equals(0)) //Add New User
            {
                #region Add User

                SiteContentSettingResult featureSetting = GetSiteFeatureSettings(FeatureEnum.User).Where(qry=>qry.ContentSettingId.Equals((int)FeatureSettingEnum.ApprovalRequired)).FirstOrDefault();
                if (featureSetting != null && featureSetting.IsAssigned)
                    userMember.IsApproved = false;
                else
                    userMember.IsApproved = true;
                UserUnicity(userMember.UserName,userMember.Email,0);
                string password = RandomGenerator.RandomString(8);
                KeyValuePair<string, string> hashedPassword = DataEncryption.CreateHashedText(password, true);
                userMember.Password = hashedPassword.Key;
                userMember.PasswordSalt = hashedPassword.Value;
                userMember.CreatedById = UserContextDetails.UserId;
                userMember.CreatedOn = DateTime.UtcNow;
                userMember.IsConfirmed = true;
                foreach (UserRole userRole in userMember.UserRoles)
                {
                    userRole.CreatedById = UserContextDetails.UserId;
                    userRole.CreatedOn = DateTime.UtcNow;
                    userRole.SiteId = UserContextDetails.SiteId;
                }
                eCollabroDbContext.Repository<UserMembership>().Insert(userMember);

                eCollabroDbContext.Save();

                //Create email
                string subject = "User Account Created";
                string body = "Your account has been created. Please see your credentials to login. " + Environment.NewLine + " Username " + userMember.UserName + Environment.NewLine + " Password " + password;
                MailMessage message = new MailMessage("*****@*****.**", userMember.Email, subject, body);
                _commonManager.SendEmail(message);
                #endregion
            }
            else //update user
            {
                #region UpdateUser
                UserMembership oldUserDetails = eCollabroDbContext.Repository<UserMembership>().Query().Include(inc=>inc.UserRoles).Filter(qry => qry.UserName.Equals(userMember.UserName)).Get().FirstOrDefault();
                if (oldUserDetails != null)
                {
                    List<UserRole> existingRoles = oldUserDetails.UserRoles.Where(qry => qry.SiteId.Equals(UserContextDetails.SiteId)).ToList();
                    UserUnicity(userMember.UserName, userMember.Email, userMember.UserId);
                    // Confirm/Approve/Locked to be managed through individual methods
                    oldUserDetails.ModifiedById = UserContextDetails.UserId;
                    oldUserDetails.ModifiedOn = DateTime.UtcNow;
                    oldUserDetails.IsActive = userMember.IsActive;
                    oldUserDetails.Email = userMember.Email;
                    // Add New Roles
                    foreach (UserRole userRole in userMember.UserRoles)
                    {
                        if (!existingRoles.Any(qry=>qry.RoleId.Equals(userRole.RoleId)))
                        {
                            oldUserDetails.UserRoles.Add(new UserRole { CreatedById = UserContextDetails.UserId, CreatedOn = DateTime.UtcNow, RoleId = userRole.RoleId, UserId = oldUserDetails.UserId, SiteId = UserContextDetails.SiteId });
                        }
                    }
                    // Remove Not selected Roles
                    foreach (UserRole userRole in existingRoles)
                    {
                        if (!userMember.UserRoles.Any(qry => qry.RoleId.Equals(userRole.RoleId)))
                        {
                            eCollabroDbContext.Repository<UserRole>().Delete(userRole);
                        }
                    }
                    eCollabroDbContext.Save();
                }
                else
                {
                    throw new DBConcurrencyException();
                }

                #endregion
            }
        }
Beispiel #5
0
        /// <summary>
        /// SetupEcollabro
        /// </summary>
        /// <param name="adminUser"></param>
        public void SetupEcollabro(UserMembership adminUser)
        {
            if (IsEcollabroSetupReady())
                throw new BusinessException(_coreValidationResourceManager.GetString(CoreValidationMessagesConstants.eCollabroAlreadySetup), CoreValidationMessagesConstants.eCollabroAlreadySetup);
            else
            {
                KeyValuePair<string, string> pass = DataEncryption.CreateHashedText(DataEncryption.Decrypt(adminUser.Password), true);

                //language
                eCollabroDbContext.Repository<lkpLanguage>().Insert(new lkpLanguage { Language = "English", LanguageCode = "en-US", CreatedById = 1, CreatedOn = DateTime.UtcNow, IsActive = true });

                //Code Formats
                eCollabroDbContext.Repository<CodeFormat>().Insert(new CodeFormat { EntityName = "Role", Suffix = "", Prefix = "RL", CurrentSeed = 1, Seprator = "", Codelength = 10 });
                eCollabroDbContext.Repository<CodeFormat>().Insert(new CodeFormat { EntityName = "Site", Suffix = "", Prefix = "ST", CurrentSeed = 1, Seprator = "", Codelength = 10 });
                eCollabroDbContext.Repository<CodeFormat>().Insert(new CodeFormat { EntityName = "Module", Suffix = "", Prefix = "MD", CurrentSeed = 2, Seprator = "", Codelength = 10 });
                eCollabroDbContext.Repository<CodeFormat>().Insert(new CodeFormat { EntityName = "Feature", Suffix = "", Prefix = "FT", CurrentSeed = 9, Seprator = "", Codelength = 10 });
                eCollabroDbContext.Repository<CodeFormat>().Insert(new CodeFormat { EntityName = "Navigation", Suffix = "", Prefix = "NAV", CurrentSeed = 13, Seprator = "", Codelength = 10 });

                //navigation type
                eCollabroDbContext.Repository<lkpNavigationType>().Insert(new lkpNavigationType { NavigationTypeCode = "NAVTYP0001", NavigationType = "None", CreatedById = 1, CreatedOn = DateTime.UtcNow, IsActive = true });
                eCollabroDbContext.Repository<lkpNavigationType>().Insert(new lkpNavigationType { NavigationTypeCode = "NAVTYP0002", NavigationType = "Content", CreatedById = 1, CreatedOn = DateTime.UtcNow, IsActive = true });
                eCollabroDbContext.Repository<lkpNavigationType>().Insert(new lkpNavigationType { NavigationTypeCode = "NAVTYP0003", NavigationType = "Feature", CreatedById = 1, CreatedOn = DateTime.UtcNow, IsActive = true });
                eCollabroDbContext.Repository<lkpNavigationType>().Insert(new lkpNavigationType { NavigationTypeCode = "NAVTYP0004", NavigationType = "Link", CreatedById = 1, CreatedOn = DateTime.UtcNow, IsActive = true });

                //Module - Setup
                Module moduleSetup = new Module { ModuleCode = "MD00000001", ModuleName = "Setup", ModuleDescription = "Site Settings/Setup Options", CreatedById = 1, CreatedOn = DateTime.UtcNow };
                moduleSetup.Features.Add(new Feature { FeatureCode = "FT00000001", FeatureName = "Manage Roles", IsNavigationLink = true, Link = "/security/roles", CreatedById = 1, CreatedOn = DateTime.UtcNow, IsActive = true });
                moduleSetup.Features.Add(new Feature { FeatureCode = "FT00000002", FeatureName = "Manage Users", IsNavigationLink = true, Link = "/security/users", CreatedById = 1, CreatedOn = DateTime.UtcNow, IsActive = true });
                moduleSetup.Features.Add(new Feature { FeatureCode = "FT00000003", FeatureName = "Manage Navigations", IsNavigationLink = true, Link = "/security/navigations", CreatedById = 1, CreatedOn = DateTime.UtcNow, IsActive = true });
                moduleSetup.Features.Add(new Feature { FeatureCode = "FT00000004", FeatureName = "Site Configuration", IsNavigationLink = true, Link = "/security/siteconfiguration", CreatedById = 1, CreatedOn = DateTime.UtcNow, IsActive = true });

                //Module Content
                Module moduleContent = new Module { ModuleCode = "MD00000002", ModuleName = "Content", ModuleDescription = "Content Module - Blog, Document Library, Image Gallery, Content Pages & Announcements", CreatedById = 1, CreatedOn = DateTime.UtcNow };
                moduleContent.Features.Add(new Feature { FeatureCode = "FT00000005", FeatureName = "Manage Content Pages", IsNavigationLink = true, Link = "/content/contentpage/categories", CreatedById = 1, CreatedOn = DateTime.UtcNow, IsActive = true });
                moduleContent.Features.Add(new Feature { FeatureCode = "FT00000006", FeatureName = "Manage Blogs", IsNavigationLink = true, Link = "/content/blog/blogcategories", CreatedById = 1, CreatedOn = DateTime.UtcNow, IsActive = true });
                moduleContent.Features.Add(new Feature { FeatureCode = "FT00000007", FeatureName = "Manage Document Libraries", IsNavigationLink = true, Link = "/content/documentlibrary/documentlibraries", CreatedById = 1, CreatedOn = DateTime.UtcNow, IsActive = true });
                moduleContent.Features.Add(new Feature { FeatureCode = "FT00000008", FeatureName = "Manage Image Galleries", IsNavigationLink = true, Link = "/content/imagegallery/imagegalleries", CreatedById = 1, CreatedOn = DateTime.UtcNow, IsActive = true });
                moduleContent.Features.Add(new Feature { FeatureCode = "FT00000009", FeatureName = "Manage Announcements", IsNavigationLink = true, Link = "/content/announcement/announcements", CreatedById = 1, CreatedOn = DateTime.UtcNow, IsActive = true });

                eCollabroDbContext.Repository<Module>().Insert(moduleSetup);
                eCollabroDbContext.Repository<Module>().Insert(moduleContent);

                //Context

                eCollabroDbContext.Repository<lkpContext>().Insert(new lkpContext { Context = "User", IsActive = true, CreatedById = 1, CreatedOn = DateTime.UtcNow });
                eCollabroDbContext.Repository<lkpContext>().Insert(new lkpContext { Context = "Content Page", IsActive = true, CreatedById = 1, CreatedOn = DateTime.UtcNow });
                eCollabroDbContext.Repository<lkpContext>().Insert(new lkpContext { Context = "Blog", IsActive = true, CreatedById = 1, CreatedOn = DateTime.UtcNow });
                eCollabroDbContext.Repository<lkpContext>().Insert(new lkpContext { Context = "Document", IsActive = true, CreatedById = 1, CreatedOn = DateTime.UtcNow });
                eCollabroDbContext.Repository<lkpContext>().Insert(new lkpContext { Context = "Image", IsActive = true, CreatedById = 1, CreatedOn = DateTime.UtcNow });
                eCollabroDbContext.Repository<lkpContext>().Insert(new lkpContext { Context = "Announcement", IsActive = true, CreatedById = 1, CreatedOn = DateTime.UtcNow });

                //Content Permission

                eCollabroDbContext.Repository<ContentPermission>().Insert(new ContentPermission { ContentPermissionName = "View Content", ContentPermissionDescription = "View Content" });
                eCollabroDbContext.Repository<ContentPermission>().Insert(new ContentPermission { ContentPermissionName = "View Unapproved Content", ContentPermissionDescription = "View Unapproved Content" });
                eCollabroDbContext.Repository<ContentPermission>().Insert(new ContentPermission { ContentPermissionName = "View Inactive Content", ContentPermissionDescription = "View Inactive Content" });
                eCollabroDbContext.Repository<ContentPermission>().Insert(new ContentPermission { ContentPermissionName = "Add Content", ContentPermissionDescription = "Add Content" });
                eCollabroDbContext.Repository<ContentPermission>().Insert(new ContentPermission { ContentPermissionName = "Edit Content", ContentPermissionDescription = "Edit Content" });
                eCollabroDbContext.Repository<ContentPermission>().Insert(new ContentPermission { ContentPermissionName = "Delete Content", ContentPermissionDescription = "Delete Content" });
                eCollabroDbContext.Repository<ContentPermission>().Insert(new ContentPermission { ContentPermissionName = "Approve Content", ContentPermissionDescription = "Approve Content" });

                //Content Setting
                eCollabroDbContext.Repository<ContentSetting>().Insert(new ContentSetting { ContentSettingName = "Approval Required", ContentSettingDescription = "Approval Required" });

                // Site
                Site site = new Site { SiteCode = "ST00000001", SiteName = "Primary", SiteDesc = "Primary Site", CreatedById = 1, CreatedOn = DateTime.UtcNow, IsActive = true };
                site.Roles.Add(new Role { RoleCode = "RL00000001", RoleName = "Site Admin", RoleDescription = "Site Admin role has access to all options available for Site.", CreatedById = 1, CreatedOn = DateTime.UtcNow, IsActive = true, IsSystem = true });

                eCollabroDbContext.Repository<Site>().Insert(site);

                // setup admin user
                adminUser.PasswordChangedDate = DateTime.UtcNow;
                adminUser.Password = pass.Key;
                adminUser.PasswordSalt = pass.Value;
                adminUser.CreatedById = 1;
                adminUser.CreatedOn = DateTime.UtcNow;
                adminUser.IsConfirmed = true;
                adminUser.IsActive = true;
                adminUser.IsApproved = true;
                adminUser.SiteCollectionAdmins.Add(new SiteCollectionAdmin { CreatedById = 1, CreatedOn = DateTime.UtcNow });
                eCollabroDbContext.Repository<UserMembership>().Insert(adminUser);

                eCollabroDbContext.Save();

                eCollabroDbContext.Repository<Navigation>().Insert(new Navigation { NavigationCode = "NAV0000001", NavigationText = "Home", AdditionalHtml = "<span class=\"glyphicon glyphicon-home\"></span>&nbsp;", SiteId = site.SiteId, NavigationTypeId = 4, Link = "/", CreatedById = 1, CreatedOn = DateTime.UtcNow, IsAnomynousAccess = true, DisplayOrder = 1, IsActive = true });
                eCollabroDbContext.Repository<Navigation>().Insert(new Navigation { NavigationCode = "NAV0000002", NavigationText = "Dashboard", AdditionalHtml = "<span class=\"glyphicon glyphicon-dashboard\"></span>&nbsp;", SiteId = site.SiteId, NavigationTypeId = 4, Link = "/home/dashboard", CreatedById = 1, CreatedOn = DateTime.UtcNow, IsAnomynousAccess = false, DisplayOrder = 2, IsActive = true });

                Navigation navigationSetup = new Navigation { NavigationCode = "NAV0000003", NavigationText = "Setup", SiteId = site.SiteId, NavigationTypeId = 1, CreatedById = 1, CreatedOn = DateTime.UtcNow, IsAnomynousAccess = false, DisplayOrder = 3, IsActive = true };
                Navigation navigationContent = new Navigation { NavigationCode = "NAV0000008", NavigationText = "Content", SiteId = site.SiteId, NavigationTypeId = 1, CreatedById = 1, CreatedOn = DateTime.UtcNow, IsAnomynousAccess = false, DisplayOrder = 8, IsActive = true };

                eCollabroDbContext.Repository<Navigation>().Insert(navigationSetup);
                eCollabroDbContext.Repository<Navigation>().Insert(navigationContent);
                eCollabroDbContext.Save();

                eCollabroDbContext.Repository<Navigation>().Insert(new Navigation { NavigationCode = "NAV0000004", NavigationText = "Roles", SiteId = site.SiteId, NavigationParentId = navigationSetup.NavigationId, NavigationTypeId = 3, FeatureId = 1, CreatedById = 1, CreatedOn = DateTime.UtcNow, IsAnomynousAccess = false, DisplayOrder = 4, IsActive = true });
                eCollabroDbContext.Repository<Navigation>().Insert(new Navigation { NavigationCode = "NAV0000005", NavigationText = "Users", SiteId = site.SiteId, NavigationParentId = navigationSetup.NavigationId, NavigationTypeId = 3, FeatureId = 2, CreatedById = 1, CreatedOn = DateTime.UtcNow, IsAnomynousAccess = false, DisplayOrder = 5, IsActive = true });
                eCollabroDbContext.Repository<Navigation>().Insert(new Navigation { NavigationCode = "NAV0000006", NavigationText = "Navigations", SiteId = site.SiteId, NavigationParentId = navigationSetup.NavigationId, NavigationTypeId = 3, FeatureId = 3, CreatedById = 1, CreatedOn = DateTime.UtcNow, IsAnomynousAccess = false, DisplayOrder = 6, IsActive = true });
                eCollabroDbContext.Repository<Navigation>().Insert(new Navigation { NavigationCode = "NAV0000007", NavigationText = "Site Settings", SiteId = site.SiteId, NavigationParentId = navigationSetup.NavigationId, NavigationTypeId = 3, FeatureId = 4, CreatedById = 1, CreatedOn = DateTime.UtcNow, IsAnomynousAccess = false, DisplayOrder = 7, IsActive = true });

                eCollabroDbContext.Repository<Navigation>().Insert(new Navigation { NavigationCode = "NAV0000009", NavigationText = "Pages", SiteId = site.SiteId, NavigationParentId = navigationContent.NavigationId, NavigationTypeId = 3, FeatureId = 5, CreatedById = 1, CreatedOn = DateTime.UtcNow, IsAnomynousAccess = false, DisplayOrder = 9, IsActive = true });
                eCollabroDbContext.Repository<Navigation>().Insert(new Navigation { NavigationCode = "NAV0000010", NavigationText = "Blogs", SiteId = site.SiteId, NavigationParentId = navigationContent.NavigationId, NavigationTypeId = 3, FeatureId = 6, CreatedById = 1, CreatedOn = DateTime.UtcNow, IsAnomynousAccess = false, DisplayOrder = 10, IsActive = true });
                eCollabroDbContext.Repository<Navigation>().Insert(new Navigation { NavigationCode = "NAV0000011", NavigationText = "Document Libraries", SiteId = site.SiteId, NavigationParentId = navigationContent.NavigationId, NavigationTypeId = 3, FeatureId = 7, CreatedById = 1, CreatedOn = DateTime.UtcNow, IsAnomynousAccess = false, DisplayOrder = 11, IsActive = true });
                eCollabroDbContext.Repository<Navigation>().Insert(new Navigation { NavigationCode = "NAV0000012", NavigationText = "Image Galleries", SiteId = site.SiteId, NavigationParentId = navigationContent.NavigationId, NavigationTypeId = 3, FeatureId = 8, CreatedById = 1, CreatedOn = DateTime.UtcNow, IsAnomynousAccess = false, DisplayOrder = 12, IsActive = true });
                eCollabroDbContext.Repository<Navigation>().Insert(new Navigation { NavigationCode = "NAV0000013", NavigationText = "Announcements", SiteId = site.SiteId, NavigationParentId = navigationContent.NavigationId, NavigationTypeId = 3, FeatureId = 9, CreatedById = 1, CreatedOn = DateTime.UtcNow, IsAnomynousAccess = false, DisplayOrder = 13, IsActive = true });

                eCollabroDbContext.Repository<UserRole>().Insert(new UserRole { RoleId = site.Roles.FirstOrDefault().RoleId, SiteId = site.SiteId, UserId = adminUser.UserId, CreatedById = 1, CreatedOn = DateTime.UtcNow, IsActive = true });

                //Feature Permission
                //Role
                for (int ctr = 1; ctr <= 6; ctr++)
                {
                    if (ctr != 2)
                        eCollabroDbContext.Repository<FeaturePermission>().Insert(new FeaturePermission { FeatureId = 1, PermissionId = ctr });
                }
                //User
                for (int ctr = 1; ctr <= 7; ctr++)
                    eCollabroDbContext.Repository<FeaturePermission>().Insert(new FeaturePermission { FeatureId = 2, PermissionId = ctr });
                //Navigation
                for (int ctr = 1; ctr <= 6; ctr++)
                {
                    if (ctr != 2)
                        eCollabroDbContext.Repository<FeaturePermission>().Insert(new FeaturePermission { FeatureId = 3, PermissionId = ctr });
                }
                //Site Settings
                eCollabroDbContext.Repository<FeaturePermission>().Insert(new FeaturePermission { FeatureId = 4, PermissionId = 1 });
                eCollabroDbContext.Repository<FeaturePermission>().Insert(new FeaturePermission { FeatureId = 4, PermissionId = 5 });
                //Content Page
                for (int ctr = 1; ctr <= 7; ctr++)
                    eCollabroDbContext.Repository<FeaturePermission>().Insert(new FeaturePermission { FeatureId = 5, PermissionId = ctr });
                //Blogs
                for (int ctr = 1; ctr <= 7; ctr++)
                    eCollabroDbContext.Repository<FeaturePermission>().Insert(new FeaturePermission { FeatureId = 6, PermissionId = ctr });
                //Document Library
                for (int ctr = 1; ctr <= 7; ctr++)
                    eCollabroDbContext.Repository<FeaturePermission>().Insert(new FeaturePermission { FeatureId = 7, PermissionId = ctr });
                //Image Gallery
                for (int ctr = 1; ctr <= 7; ctr++)
                    eCollabroDbContext.Repository<FeaturePermission>().Insert(new FeaturePermission { FeatureId = 8, PermissionId = ctr });
                //Announcement
                for (int ctr = 1; ctr <= 7; ctr++)
                    eCollabroDbContext.Repository<FeaturePermission>().Insert(new FeaturePermission { FeatureId = 9, PermissionId = ctr });

                //Content Setting
                eCollabroDbContext.Repository<FeatureContentSetting>().Insert(new FeatureContentSetting { FeatureId = 2, ContentSettingId = 1 }); //User,ApprovalRequired

                eCollabroDbContext.Repository<FeatureContentSetting>().Insert(new FeatureContentSetting { FeatureId = 5, ContentSettingId = 1 }); //Content Page,ApprovalRequired
                eCollabroDbContext.Repository<FeatureContentSetting>().Insert(new FeatureContentSetting { FeatureId = 6, ContentSettingId = 1 }); //Blog,ApprovalRequired
                eCollabroDbContext.Repository<FeatureContentSetting>().Insert(new FeatureContentSetting { FeatureId = 7, ContentSettingId = 1 }); //Document Library,ApprovalRequired
                eCollabroDbContext.Repository<FeatureContentSetting>().Insert(new FeatureContentSetting { FeatureId = 8, ContentSettingId = 1 }); //Image Gallery,ApprovalRequired
                eCollabroDbContext.Repository<FeatureContentSetting>().Insert(new FeatureContentSetting { FeatureId = 9, ContentSettingId = 1 }); //Announcement,ApprovalRequired

                // add all features to primary site
                for (int ctr = 1; ctr <= 9; ctr++)
                    eCollabroDbContext.Repository<SiteFeature>().Insert(new SiteFeature { SiteId = site.SiteId, FeatureId = ctr, CreatedById = 1, CreatedOn = DateTime.UtcNow });

                eCollabroDbContext.Save();
                ExecuteScripts();
            }
        }