/// <summary> /// Fixed: /// </summary> public static string Change(string reference, long id) { if (!Contract.Export()) { return(Error.Types.Restricted.MessageJson()); } var exportSettingModel = new ExportSettingModel() .Get(where : Rds.ExportSettingsWhere() .ExportSettingId(Forms.Long("ExportSettings_ExportSettingId"))); var invalid = ExportSettingValidator.OnExporting( SiteSettingsUtilities.GetByReference(reference, id)); switch (invalid) { case Error.Types.None: break; default: return(invalid.MessageJson()); } SetSessions(exportSettingModel); exportSettingModel.Session_ExportColumns(Jsons.ToJson(exportSettingModel.ExportColumns)); return(new ResponseCollection() .Html("#ExportSettings_Columns", new HtmlBuilder() .SelectableItems(listItemCollection: exportSettingModel.ExportColumnHash())) .Val("#ExportSettings_Title", exportSettingModel.Title.Value) .Val("#ExportSettings_AddHeader", exportSettingModel.AddHeader) .ClearFormData() .ToJson()); }
/// <summary> /// Fixed: /// </summary> public static string Delete(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()); } var error = exportSettingModel.Delete(); if (error.Has()) { return(error.MessageJson()); } else { return(EditorJson(ss, reference, id)); } }
/// <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()); } }
public void SetByModel(ExportSettingModel exportSettingModel) { ReferenceType = exportSettingModel.ReferenceType; ReferenceId = exportSettingModel.ReferenceId; Title = exportSettingModel.Title; AddHeader = exportSettingModel.AddHeader; ExportColumns = exportSettingModel.ExportColumns; Comments = exportSettingModel.Comments; Creator = exportSettingModel.Creator; Updator = exportSettingModel.Updator; CreatedTime = exportSettingModel.CreatedTime; UpdatedTime = exportSettingModel.UpdatedTime; VerUp = exportSettingModel.VerUp; Comments = exportSettingModel.Comments; }
public void SetByModel(ExportSettingModel exportSettingModel) { ReferenceType = exportSettingModel.ReferenceType; ReferenceId = exportSettingModel.ReferenceId; Title = exportSettingModel.Title; AddHeader = exportSettingModel.AddHeader; ExportColumns = exportSettingModel.ExportColumns; Comments = exportSettingModel.Comments; Creator = exportSettingModel.Creator; Updator = exportSettingModel.Updator; CreatedTime = exportSettingModel.CreatedTime; UpdatedTime = exportSettingModel.UpdatedTime; VerUp = exportSettingModel.VerUp; Comments = exportSettingModel.Comments; ClassHash = exportSettingModel.ClassHash; NumHash = exportSettingModel.NumHash; DateHash = exportSettingModel.DateHash; DescriptionHash = exportSettingModel.DescriptionHash; CheckHash = exportSettingModel.CheckHash; AttachmentsHash = exportSettingModel.AttachmentsHash; }
/// <summary> /// Fixed: /// </summary> public static void SetSessions(ExportSettingModel exportSettingModel) { exportSettingModel.Session_Title(exportSettingModel.Title); exportSettingModel.Session_AddHeader(exportSettingModel.AddHeader); exportSettingModel.Session_ExportColumns(Jsons.ToJson(exportSettingModel.ExportColumns)); }