/// <summary> /// GetSiteConfiguration /// </summary> /// <param name="siteId"></param> /// <returns></returns> public SiteConfiguration GetSiteConfiguration() { SiteConfiguration siteConfiguration = eCollabroDbContext.Repository<SiteConfiguration>().Query().Filter(qry => qry.SiteId.Equals(UserContextDetails.SiteId)).Get().FirstOrDefault(); if (siteConfiguration == null) { siteConfiguration = new SiteConfiguration(); siteConfiguration.SiteId = UserContextDetails.SiteId; } return siteConfiguration; }
/// <summary> /// SaveSiteConfiguration /// </summary> /// <param name="siteConfiguration"></param> public void SaveSiteConfiguration(SiteConfiguration siteConfiguration) { #region Check Permission // Check Permission List<PermissionEnum> userPermissions = GetUserFeaturePermissions(UserContextDetails.UserId, FeatureEnum.SiteConfiguration); if (!userPermissions.Contains(PermissionEnum.EditContent)) throw new BusinessException(_coreValidationResourceManager.GetString(CoreValidationMessagesConstants.UnAuthorized), CoreValidationMessagesConstants.UnAuthorized); #endregion if (eCollabroDbContext.Repository<SiteConfiguration>().IsEntityAttachedToDB(siteConfiguration)) { eCollabroDbContext.Save(); // Service Call after get; } else { SiteConfiguration siteConfigurationDB = eCollabroDbContext.Repository<SiteConfiguration>().Query().Filter(qry => qry.SiteId.Equals(UserContextDetails.SiteId)).Get().FirstOrDefault(); if (siteConfigurationDB == null) { siteConfigurationDB = siteConfiguration; eCollabroDbContext.Repository<SiteConfiguration>().Insert(siteConfigurationDB); } siteConfigurationDB.ModifiedById = UserContextDetails.UserId; siteConfigurationDB.ModifiedOn = DateTime.UtcNow; siteConfigurationDB.AllowRegistration = siteConfiguration.AllowRegistration; siteConfigurationDB.RegistrationDefaultRoleId = siteConfiguration.RegistrationDefaultRoleId; siteConfigurationDB.AccountRequireEmailVerification = siteConfiguration.AccountRequireEmailVerification; eCollabroDbContext.Save(); } }