コード例 #1
0
        public ActionResult SiteOwner(SiteOwnerModel model)
        {
            // Check permissions
            if (!_permissionService.Authorize(PermissionProvider.ManageSiteOwner))
                return AccessDeniedView();

            // Build breadcrumbs
            PrepareBreadcrumbs();
            AddBreadcrumb("Site Owner", null);

            // Ensure the form is valid
            if (ModelState.IsValid)
            {
                try
                {
                    _ownerSettings.MailDefaultCredentials = model.MailUseDefaultCredentials;
                    _ownerSettings.MailEnableSSL = model.MailEnableSSL;
                    _ownerSettings.MailFromDisplayName = model.MailFromDisplayName;
                    _ownerSettings.MailFromEmail = model.MailFromEmail;
                    _ownerSettings.MailHost = model.MailHost;
                    _ownerSettings.MailPassword = model.MailPassword;
                    _ownerSettings.MailPort = model.MailPort.ToString();
                    _ownerSettings.MailUsername = model.MailUsername;
                    _ownerSettings.TwitterAccessToken = model.TwitterAccessToken;
                    _ownerSettings.TwitterAccessTokenSecret = model.TwitterAccessTokenSecret;

                    _settingService.SaveSetting(_ownerSettings);
                    SuccessNotification("The site owner settings have been updated successfully.");
                }
                catch
                {
                    ErrorNotification("An error occurred saving the site owner settings, please try again.");
                }
            }
            else
            {
                ErrorNotification("We were unable to make the change, please review the form and correct the errors.");
            }

            return View(model);
        }
コード例 #2
0
        public ActionResult SiteOwner()
        {
            // Check the user's permissions
            if (!_permissionService.Authorize(PermissionProvider.ManageSiteOwner))
                return AccessDeniedView();

            // Build breadcrumbs
            PrepareBreadcrumbs();
            AddBreadcrumb("Site Owner", null);

            var model = new SiteOwnerModel
            {
                MailEnableSSL = _ownerSettings.MailEnableSSL,
                MailFromDisplayName = _ownerSettings.MailFromDisplayName,
                MailFromEmail = _ownerSettings.MailFromEmail,
                MailHost = _ownerSettings.MailHost,
                MailPassword = _ownerSettings.MailPassword,
                MailPort = int.Parse(_ownerSettings.MailPort),
                MailUseDefaultCredentials = _ownerSettings.MailDefaultCredentials,
                MailUsername = _ownerSettings.MailUsername,
                TwitterAccessToken = _ownerSettings.TwitterAccessToken,
                TwitterAccessTokenSecret = _ownerSettings.TwitterAccessTokenSecret
            };

            return View(model);
        }