コード例 #1
0
 public ActionResult Index()
 {
     using (UnitOfWorkManager.NewUnitOfWork())
     {
         var settings = SettingsService.GetSettings();
         var viewModel = new SocialSettingsViewModel
         {
             EnableSocialLogins = settings.EnableSocialLogins == true,
             FacebookAppId = SiteConstants.FacebookAppId,
             FacebookAppSecret = SiteConstants.FacebookAppSecret,
             GooglePlusAppId = SiteConstants.GooglePlusAppId,
             GooglePlusAppSecret = SiteConstants.GooglePlusAppSecret
         };
         return View(viewModel);
     }
 }
コード例 #2
0
        public ActionResult Index(SocialSettingsViewModel viewModel)
        {
            using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork())
            {

                var settings = SettingsService.GetSettings(false);

                settings.EnableSocialLogins = viewModel.EnableSocialLogins;

                // Repopulate the view model
                viewModel.FacebookAppId = SiteConstants.Instance.FacebookAppId;
                viewModel.FacebookAppSecret = SiteConstants.Instance.FacebookAppSecret;
                viewModel.GooglePlusAppId = SiteConstants.Instance.GooglePlusAppId;
                viewModel.GooglePlusAppSecret = SiteConstants.Instance.GooglePlusAppSecret;
                viewModel.MicrosoftAppId = SiteConstants.Instance.MicrosoftAppId;
                viewModel.MicrosoftAppSecret = SiteConstants.Instance.MicrosoftAppSecret;

                try
                {
                    unitOfWork.Commit();
                    _cacheService.ClearStartsWith(CacheKeys.Settings.Main);
                    // Show a message
                    ShowMessage(new GenericMessageViewModel
                    {
                        Message = "Updated",
                        MessageType = GenericMessages.success
                    });

                }
                catch (Exception ex)
                {
                    LoggingService.Error(ex);
                    unitOfWork.Rollback();

                    // Show a message
                    ShowMessage(new GenericMessageViewModel
                    {
                        Message = "Error, please check log",
                        MessageType = GenericMessages.danger
                    });
                }

                return View(viewModel);
            }
        }