Ejemplo n.º 1
0
        /// <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());
        }
Ejemplo n.º 2
0
        /// <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));
            }
        }
Ejemplo n.º 3
0
        /// <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());
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Fixed:
        /// </summary>
        private static string EditorJson(SiteSettings ss, string reference, long id)
        {
            var invalid = ExportSettingValidator.OnExporting(ss);

            switch (invalid)
            {
            case Error.Types.None: break;

            default: return(invalid.MessageJson());
            }
            return(EditorResponse(new ResponseCollection(), ss, reference, id).ToJson());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public string Set(SiteSettings ss, long id)
        {
            var invalid = ExportSettingValidator.OnExporting(ss);

            switch (invalid)
            {
            case Error.Types.None: break;

            default: return(invalid.MessageJson());
            }
            var res = new ExportSettingsResponseCollection(this);

            ExportColumns = Session_ExportColumns();
            ExportColumns.SetExport(
                res,
                Forms.ControlId(),
                Forms.List("ExportSettings_Columns"),
                GetSiteSettings());
            ExportSettingUtilities.SetSessions(this);
            return(res.ToJson());
        }