예제 #1
0
        public static Settings SettingsViewModelToSettings(EditSettingsViewModel settingsViewModel, Settings existingSettings)
        {
            //NOTE: The only reason some properties are commented out, are because those items were
            //      moved to their own page when the admin was refactored.

            existingSettings.Id = settingsViewModel.Id;
            existingSettings.ForumName = settingsViewModel.ForumName;
            existingSettings.ForumUrl = settingsViewModel.ForumUrl;
            existingSettings.IsClosed = settingsViewModel.IsClosed;
            existingSettings.EnableRSSFeeds = settingsViewModel.EnableRSSFeeds;
            existingSettings.DisplayEditedBy = settingsViewModel.DisplayEditedBy;
            existingSettings.EnableMarkAsSolution = settingsViewModel.EnableMarkAsSolution;
            existingSettings.MarkAsSolutionReminderTimeFrame = settingsViewModel.MarkAsSolutionReminderTimeFrame;
            //existingSettings.EnableSpamReporting = settingsViewModel.EnableSpamReporting;
            //existingSettings.EnableMemberReporting = settingsViewModel.EnableMemberReporting;
            existingSettings.EnableEmailSubscriptions = settingsViewModel.EnableEmailSubscriptions;
            existingSettings.ManuallyAuthoriseNewMembers = settingsViewModel.ManuallyAuthoriseNewMembers;
            existingSettings.EmailAdminOnNewMemberSignUp = settingsViewModel.EmailAdminOnNewMemberSignUp;
            existingSettings.TopicsPerPage = settingsViewModel.TopicsPerPage;
            existingSettings.PostsPerPage = settingsViewModel.PostsPerPage;
            existingSettings.ActivitiesPerPage = settingsViewModel.ActivitiesPerPage;
            existingSettings.EnablePrivateMessages = settingsViewModel.EnablePrivateMessages;
            existingSettings.MaxPrivateMessagesPerMember = settingsViewModel.MaxPrivateMessagesPerMember;
            existingSettings.PrivateMessageFloodControl = settingsViewModel.PrivateMessageFloodControl;
            existingSettings.EnableSignatures = settingsViewModel.EnableSignatures;
            existingSettings.EnablePoints = settingsViewModel.EnablePoints;
            existingSettings.PointsAllowedToVoteAmount = settingsViewModel.PointsAllowedToVoteAmount;
            existingSettings.PointsAllowedForExtendedProfile = settingsViewModel.PointsAllowedForExtendedProfile;
            existingSettings.PointsAddedPerPost = settingsViewModel.PointsAddedPerPost;
            existingSettings.PointsAddedPostiveVote = settingsViewModel.PointsAddedPostiveVote;
            existingSettings.PointsDeductedNagativeVote = settingsViewModel.PointsDeductedNagativeVote;
            existingSettings.PointsAddedForSolution = settingsViewModel.PointsAddedForSolution;
            existingSettings.AdminEmailAddress = settingsViewModel.AdminEmailAddress;
            existingSettings.NotificationReplyEmail = settingsViewModel.NotificationReplyEmail;
            existingSettings.SMTP = settingsViewModel.SMTP;
            existingSettings.SMTPUsername = settingsViewModel.SMTPUsername;
            existingSettings.SMTPPassword = settingsViewModel.SMTPPassword;
            existingSettings.Theme = settingsViewModel.Theme;
            //existingSettings.AkismentKey = settingsViewModel.AkismentKey;
            //existingSettings.EnableAkisment = settingsViewModel.EnableAkisment;
            existingSettings.SMTPPort = settingsViewModel.SMTPPort.ToString();
            //existingSettings.SpamQuestion = settingsViewModel.SpamQuestion;
            //existingSettings.SpamAnswer = settingsViewModel.SpamAnswer;
            existingSettings.SMTPEnableSSL = settingsViewModel.SMTPEnableSSL;
            //existingSettings.EnableSocialLogins = settingsViewModel.EnableSocialLogins;
            existingSettings.EnablePolls = settingsViewModel.EnablePolls;
            existingSettings.SuspendRegistration = settingsViewModel.SuspendRegistration;
            existingSettings.NewMemberEmailConfirmation = settingsViewModel.NewMemberEmailConfirmation;
            existingSettings.PageTitle = settingsViewModel.PageTitle;
            existingSettings.MetaDesc = settingsViewModel.MetaDesc;
            existingSettings.EnableEmoticons = settingsViewModel.EnableEmoticons;
            existingSettings.DisableDislikeButton = settingsViewModel.DisableDislikeButton;
            existingSettings.AgreeToTermsAndConditions = settingsViewModel.AgreeToTermsAndConditions;
            existingSettings.DisableStandardRegistration = settingsViewModel.DisableStandardRegistration;
            existingSettings.TermsAndConditions = settingsViewModel.TermsAndConditions;
            return existingSettings;
        }
예제 #2
0
        public ActionResult Index(EditSettingsViewModel settingsViewModel)
        {
            if (ModelState.IsValid)
            {
                using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork())
                {
                    try
                    {

                        var existingSettings = SettingsService.GetSettings();
                        var updatedSettings = ViewModelMapping.SettingsViewModelToSettings(settingsViewModel, existingSettings);

                        // Map over viewModel from
                        if (settingsViewModel.NewMemberStartingRole != null)
                        {
                            updatedSettings.NewMemberStartingRole =
                                _roleService.GetRole(settingsViewModel.NewMemberStartingRole.Value);
                        }

                        if (settingsViewModel.DefaultLanguage != null)
                        {
                            updatedSettings.DefaultLanguage =
                                LocalizationService.Get(settingsViewModel.DefaultLanguage.Value);
                        }

                        var culture = new CultureInfo(updatedSettings.DefaultLanguage.LanguageCulture);

                        unitOfWork.Commit();

                        // Set the culture session too
                        Session["Culture"] = culture;
                    }
                    catch (Exception ex)
                    {
                        unitOfWork.Rollback();
                        LoggingService.Error(ex);
                    }
                }

                // All good clear cache and get reliant lists
                using (UnitOfWorkManager.NewUnitOfWork())
                {
                    TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel
                    {
                        Message = "Settings Updated",
                        MessageType = GenericMessages.success
                    };
                    settingsViewModel.Themes = AppHelpers.GetThemeFolders();
                    settingsViewModel.Roles = _roleService.AllRoles().ToList();
                    settingsViewModel.Languages = LocalizationService.AllLanguages.ToList();
                }
            }
            return View(settingsViewModel);
        }
예제 #3
0
        public static EditSettingsViewModel SettingsToSettingsViewModel(Settings currentSettings)
        {
            var settingViewModel = new EditSettingsViewModel
            {
                Id = currentSettings.Id,
                ForumName = currentSettings.ForumName,
                ForumUrl = currentSettings.ForumUrl,
                IsClosed = currentSettings.IsClosed,
                EnableRSSFeeds = currentSettings.EnableRSSFeeds,
                DisplayEditedBy = currentSettings.DisplayEditedBy,
                EnableMarkAsSolution = currentSettings.EnableMarkAsSolution,
                EnableSpamReporting = currentSettings.EnableSpamReporting,
                EnableMemberReporting = currentSettings.EnableMemberReporting,
                EnableEmailSubscriptions = currentSettings.EnableEmailSubscriptions,
                ManuallyAuthoriseNewMembers = currentSettings.ManuallyAuthoriseNewMembers,
                EmailAdminOnNewMemberSignUp = currentSettings.EmailAdminOnNewMemberSignUp,
                TopicsPerPage = currentSettings.TopicsPerPage,
                PostsPerPage = currentSettings.PostsPerPage,
                ActivitiesPerPage = currentSettings.ActivitiesPerPage,
                EnablePrivateMessages = currentSettings.EnablePrivateMessages,
                MaxPrivateMessagesPerMember = currentSettings.MaxPrivateMessagesPerMember,
                PrivateMessageFloodControl = currentSettings.PrivateMessageFloodControl,
                EnableSignatures = currentSettings.EnableSignatures,
                EnablePoints = currentSettings.EnablePoints,
                PointsAllowedToVoteAmount = currentSettings.PointsAllowedToVoteAmount,
                PointsAddedPerPost = currentSettings.PointsAddedPerPost,
                PointsAddedPostiveVote = currentSettings.PointsAddedPostiveVote,
                PointsDeductedNagativeVote = currentSettings.PointsDeductedNagativeVote,
                PointsAddedForSolution = currentSettings.PointsAddedForSolution,
                AdminEmailAddress = currentSettings.AdminEmailAddress,
                NotificationReplyEmail = currentSettings.NotificationReplyEmail,
                SMTP = currentSettings.SMTP,
                SMTPUsername = currentSettings.SMTPUsername,
                SMTPPassword = currentSettings.SMTPPassword,
                AkismentKey = currentSettings.AkismentKey,
                EnableAkisment = currentSettings.EnableAkisment != null && (bool)currentSettings.EnableAkisment,
                NewMemberEmailConfirmation = currentSettings.NewMemberEmailConfirmation != null && (bool)currentSettings.NewMemberEmailConfirmation,
                Theme = currentSettings.Theme,
                SMTPPort = string.IsNullOrEmpty(currentSettings.SMTPPort) ? null : (int?)(Convert.ToInt32(currentSettings.SMTPPort)),
                SpamQuestion = currentSettings.SpamQuestion,
                SpamAnswer = currentSettings.SpamAnswer,
                Themes = AppHelpers.GetThemeFolders(),
                SMTPEnableSSL = currentSettings.SMTPEnableSSL ?? false,
                EnableSocialLogins = currentSettings.EnableSocialLogins ?? false,
                EnablePolls = currentSettings.EnablePolls ?? false,
                SuspendRegistration = currentSettings.SuspendRegistration ?? false
            };

            return settingViewModel;
        }
예제 #4
0
 public static Settings SettingsViewModelToSettings(EditSettingsViewModel settingsViewModel, Settings existingSettings)
 {
     existingSettings.Id = settingsViewModel.Id;
     existingSettings.ForumName = settingsViewModel.ForumName;
     existingSettings.ForumUrl = settingsViewModel.ForumUrl;
     existingSettings.IsClosed = settingsViewModel.IsClosed;
     existingSettings.EnableRSSFeeds = settingsViewModel.EnableRSSFeeds;
     existingSettings.DisplayEditedBy = settingsViewModel.DisplayEditedBy;
     existingSettings.EnableMarkAsSolution = settingsViewModel.EnableMarkAsSolution;
     existingSettings.EnableSpamReporting = settingsViewModel.EnableSpamReporting;
     existingSettings.EnableMemberReporting = settingsViewModel.EnableMemberReporting;
     existingSettings.EnableEmailSubscriptions = settingsViewModel.EnableEmailSubscriptions;
     existingSettings.ManuallyAuthoriseNewMembers = settingsViewModel.ManuallyAuthoriseNewMembers;
     existingSettings.EmailAdminOnNewMemberSignUp = settingsViewModel.EmailAdminOnNewMemberSignUp;
     existingSettings.TopicsPerPage = settingsViewModel.TopicsPerPage;
     existingSettings.PostsPerPage = settingsViewModel.PostsPerPage;
     existingSettings.ActivitiesPerPage = settingsViewModel.ActivitiesPerPage;
     existingSettings.EnablePrivateMessages = settingsViewModel.EnablePrivateMessages;
     existingSettings.MaxPrivateMessagesPerMember = settingsViewModel.MaxPrivateMessagesPerMember;
     existingSettings.PrivateMessageFloodControl = settingsViewModel.PrivateMessageFloodControl;
     existingSettings.EnableSignatures = settingsViewModel.EnableSignatures;
     existingSettings.EnablePoints = settingsViewModel.EnablePoints;
     existingSettings.PointsAllowedToVoteAmount = settingsViewModel.PointsAllowedToVoteAmount;
     existingSettings.PointsAddedPerPost = settingsViewModel.PointsAddedPerPost;
     existingSettings.PointsAddedPostiveVote = settingsViewModel.PointsAddedPostiveVote;
     existingSettings.PointsDeductedNagativeVote = settingsViewModel.PointsDeductedNagativeVote;
     existingSettings.PointsAddedForSolution = settingsViewModel.PointsAddedForSolution;
     existingSettings.AdminEmailAddress = settingsViewModel.AdminEmailAddress;
     existingSettings.NotificationReplyEmail = settingsViewModel.NotificationReplyEmail;
     existingSettings.SMTP = settingsViewModel.SMTP;
     existingSettings.SMTPUsername = settingsViewModel.SMTPUsername;
     existingSettings.SMTPPassword = settingsViewModel.SMTPPassword;
     existingSettings.Theme = settingsViewModel.Theme;
     existingSettings.AkismentKey = settingsViewModel.AkismentKey;
     existingSettings.EnableAkisment = settingsViewModel.EnableAkisment;
     existingSettings.SMTPPort = settingsViewModel.SMTPPort.ToString();
     existingSettings.SpamQuestion = settingsViewModel.SpamQuestion;
     existingSettings.SpamAnswer = settingsViewModel.SpamAnswer;
     existingSettings.SMTPEnableSSL = settingsViewModel.SMTPEnableSSL;
     existingSettings.EnableSocialLogins = settingsViewModel.EnableSocialLogins;
     existingSettings.EnablePolls = settingsViewModel.EnablePolls;
     existingSettings.SuspendRegistration = settingsViewModel.SuspendRegistration;
     existingSettings.NewMemberEmailConfirmation = settingsViewModel.NewMemberEmailConfirmation;
     existingSettings.PageTitle = settingsViewModel.PageTitle;
     existingSettings.MetaDesc = settingsViewModel.MetaDesc;
     return existingSettings;
 }