/// <summary> /// Fixed: /// </summary> public static HtmlBuilder OutgoingMailsForm( this HtmlBuilder hb, Context context, string referenceType, long referenceId, int referenceVer) { var ss = SiteSettingsUtilities.GetByReference( context: context, reference: context.Controller, referenceId: referenceId); return(hb.Form( attributes: new HtmlAttributes() .Id("OutgoingMailsForm") .Action(Locations.Action(context.Controller, referenceId, "OutgoingMails")), action: () => new OutgoingMailCollection( context: context, where : Rds.OutgoingMailsWhere() .ReferenceType(referenceType) .ReferenceId(referenceId) .ReferenceVer(referenceVer, _operator: "<="), orderBy: Rds.OutgoingMailsOrderBy() .OutgoingMailId(SqlOrderBy.Types.desc)) .ForEach(outgoingMailModel => hb .OutgoingMailListItem( context: context, ss: ss, outgoingMailModel: outgoingMailModel)))); }
/// <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 EditorJson(string reference, long id) { if (!Contract.Export()) { return(Error.Types.Restricted.MessageJson()); } return(EditorJson(SiteSettingsUtilities.GetByReference(reference, id), reference, id)); }
/// <summary> /// Fixed: /// </summary> public static string Set(string reference, long id) { if (!Contract.Export()) { return(Error.Types.Restricted.MessageJson()); } var ss = SiteSettingsUtilities.GetByReference(reference, id); return(new ExportSettingModel(ss.ReferenceType, id).Set(ss, 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()); } }