public static ErrorData OnCreating(Context context, ServerScript serverScript)
 {
     try
     {
         ServerScriptUtilities.Execute(
             context: context,
             ss: new SiteSettings
         {
             EditorColumnHash = new Dictionary <string, List <string> >(),
             ColumnHash       = new Dictionary <string, Column>()
         },
             itemModel: new BaseItemModel(),
             view: null,
             scripts: new ServerScript[]
         {
             serverScript
         });
     }
     catch (Exception ex)
     {
         while (ex.InnerException != null)
         {
             ex = ex.InnerException;
         }
         return(new ErrorData(type: Error.Types.IncorrectServerScript, data: ex.Message));
     }
     return(new ErrorData(type: Error.Types.None));
 }
Exemple #2
0
 public bool Delete(object id)
 {
     if (OnTesting)
     {
         return(false);
     }
     return(ServerScriptUtilities.Delete(
                context: Context,
                id: id.ToLong()));
 }
Exemple #3
0
 public long BulkDelete(object id, string json)
 {
     if (OnTesting)
     {
         return(0);
     }
     return(ServerScriptUtilities.BulkDelete(
                context: Context,
                id: id.ToLong(),
                apiRequestBody: json));
 }
Exemple #4
0
 public bool Update(object id, object model)
 {
     if (OnTesting)
     {
         return(false);
     }
     return(ServerScriptUtilities.Update(
                context: Context,
                id: id.ToLong(),
                model: model));
 }
Exemple #5
0
        public long Count(object siteId, string view = null)
        {
            var ss = SiteSettingsUtilities.Get(
                context: Context,
                siteId: siteId.ToLong());

            return(ServerScriptUtilities.Aggregate(
                       context: Context,
                       ss: ss,
                       view: view));
        }
Exemple #6
0
 public ServerScriptModelApiModel[] Get(object id, string view = null)
 {
     if (OnTesting)
     {
         return(new ServerScriptModelApiModel[0]);
     }
     return(ServerScriptUtilities.Get(
                context: Context,
                id: id.ToLong(),
                view: view,
                onTesting: OnTesting));
 }
Exemple #7
0
        private decimal CreateAggregate(object siteId, string columnName, string view, Sqls.Functions function)
        {
            var ss = SiteSettingsUtilities.Get(
                context: Context,
                siteId: siteId.ToLong());

            return(ServerScriptUtilities.Aggregate(
                       context: Context,
                       ss: ss,
                       view: view,
                       columnName: columnName,
                       function: function));
        }
Exemple #8
0
        public ServerScriptModelApiModel New()
        {
            var itemModel  = new IssueModel();
            var apiContext = ServerScriptUtilities.CreateContext(
                context: Context,
                action: "New",
                id: 0,
                apiRequestBody: string.Empty);
            var ss = new SiteSettings(
                context: apiContext,
                referenceType: "Issues");

            itemModel.SetDefault(
                context: apiContext,
                ss: ss);
            var apiModel = new ServerScriptModelApiModel(
                context: Context,
                model: itemModel,
                onTesting: OnTesting);

            return(apiModel);
        }