public RecaptchaV2Config GetData() { RecaptchaV2Config data = new RecaptchaV2Config(); ObjectSupport.CopyData(this, data); return(data); }
public async Task <RecaptchaV2Config> GetItemAsync() { RecaptchaV2Config config = await DataProvider.GetAsync(KEY); if (config == null) { config = new RecaptchaV2Config(); await AddConfigAsync(config); } return(config); }
public async Task <ActionResult> RecaptchaV2Config() { using (RecaptchaV2ConfigDataProvider dataProvider = new RecaptchaV2ConfigDataProvider()) { EditModel model = new EditModel { }; RecaptchaV2Config data = await dataProvider.GetItemAsync(); model.SetData(data); return(View(model)); } }
public async Task AddConfigAsync(RecaptchaV2Config data) { data.Key = KEY; if (!await DataProvider.AddAsync(data)) { throw new InternalError("Unexpected error adding RecaptchaV2 Settings"); } await Auditing.AddAuditAsync($"{nameof(RecaptchaV2ConfigDataProvider)}.{nameof(AddConfigAsync)}", "Config", Guid.Empty, "Add RecaptchaV2 Config", DataBefore : null, DataAfter : data, ExpensiveMultiInstance : true ); }
/// <summary> /// Called by the framework so the component can add component specific client-side configuration options and localizations to the page. /// </summary> /// <param name="manager">The YetaWF.Core.Support.Manager instance of current HTTP request.</param> public async Task AddSupportAsync(YetaWFManager manager) { RecaptchaV2Config config = await RecaptchaV2Config.LoadRecaptchaV2ConfigAsync(); if (string.IsNullOrWhiteSpace(config.PublicKey)) { throw new InternalError("The Recaptcha configuration settings are missing - no public key found"); } ScriptManager scripts = manager.ScriptManager; string area = AreaRegistration.CurrentPackage.AreaName; scripts.AddConfigOption(area, "SiteKey", config.PublicKey); scripts.AddConfigOption(area, "Theme", config.GetTheme()); scripts.AddConfigOption(area, "Size", config.GetSize()); }
public async Task UpdateConfigAsync(RecaptchaV2Config data) { RecaptchaV2Config origConfig = Auditing.Active ? await GetItemAsync() : null; data.Key = KEY; UpdateStatusEnum status = await DataProvider.UpdateAsync(data.Key, data.Key, data); if (status != UpdateStatusEnum.OK) { throw new InternalError("Can't save captcha configuration {0}", status); } await Auditing.AddAuditAsync($"{nameof(RecaptchaV2ConfigDataProvider)}.{nameof(UpdateConfigAsync)}", "Config", Guid.Empty, "Update RecaptchaV2 Config", DataBefore : origConfig, DataAfter : data, ExpensiveMultiInstance : true ); }
public async Task <ActionResult> RecaptchaV2Config_Partial(EditModel model) { using (RecaptchaV2ConfigDataProvider dataProvider = new RecaptchaV2ConfigDataProvider()) { RecaptchaV2Config data = await dataProvider.GetItemAsync();// get the original item if (!ModelState.IsValid) { return(PartialView(model)); } ObjectSupport.CopyData(model, data); // merge new data into original model.SetData(data); // and all the data back into model for final display await dataProvider.UpdateConfigAsync(data); return(FormProcessed(model, this.__ResStr("okSaved", "Captcha configuration saved"))); } }
internal static async Task SaveRecaptchaV2Config(RecaptchaV2Config config) { using (RecaptchaV2ConfigDataProvider dp = new RecaptchaV2ConfigDataProvider()) { await dp.UpdateConfigAsync(config); } }
public void SetData(RecaptchaV2Config data) { ObjectSupport.CopyData(data, this); }