/// <summary> /// Fixed: /// </summary> public static string UpdateOrCreate(string reference, long id) { if (!Contract.Export()) { return(Error.Types.Restricted.MessageJson()); } var ss = SiteSettingsUtilities.GetByReference(reference, id); var exportSettingModel = new ExportSettingModel( ss.ReferenceType, id, withTitle: true); var invalid = ExportSettingValidator.OnExporting(ss); switch (invalid) { case Error.Types.None: break; default: return(invalid.MessageJson()); } if (exportSettingModel.ExportColumns.ReferenceType.IsNullOrEmpty()) { exportSettingModel.ExportColumns.ReferenceType = exportSettingModel.ReferenceType; } if (Forms.Data("ExportSettings_Title") == string.Empty) { exportSettingModel.Title = new Title(0, Unique.New( new ExportSettingCollection( where : Rds.ExportSettingsWhere() .ReferenceId(exportSettingModel.ReferenceId)) .Select(o => o.Title?.Value), Displays.Setting())); } var error = exportSettingModel.UpdateOrCreate( where : Rds.ExportSettingsWhere() .ReferenceId(exportSettingModel.ReferenceId) .Title(exportSettingModel.Title.Value)); if (error.Has()) { return(error.MessageJson()); } else { return(new ResponseCollection() .Html( "#ExportSettings_ExportSettingId", new HtmlBuilder().OptionCollection( optionCollection: Collection(ss.ReferenceType, id).ToDictionary( o => o.ExportSettingId.ToString(), o => new ControlData(o.Title.Value)), selectedValue: exportSettingModel.ExportSettingId.ToString(), addSelectedValue: false)) .Message(Messages.Updated(exportSettingModel.Title.ToString())) .Val("#ExportSettings_Title", exportSettingModel.Title.Value) .ToJson()); } }