public static ErrorData OnCreating(
            Context context, SiteSettings ss, IssueModel issueModel, bool api = false)
        {
            if (api)
            {
                if ((!Parameters.Api.Enabled ||
                     context.ContractSettings.Api == false ||
                     context.UserSettings?.AllowApi(context: context) == false))
                {
                    return(new ErrorData(type: Error.Types.InvalidRequest));
                }
                if (context.InvalidJsonData)
                {
                    return(new ErrorData(type: Error.Types.InvalidJsonData));
                }
            }
            if (ss.LockedTable())
            {
                return(new ErrorData(
                           type: Error.Types.LockedTable,
                           data: new string[]
                {
                    ss.LockedTableUser.Name,
                    ss.LockedTableTime.DisplayValue.ToString(context.CultureInfo())
                }));
            }
            if (!context.CanCreate(ss: ss) || issueModel.ReadOnly)
            {
                return(!context.CanRead(ss: ss)
                    ? new ErrorData(type: Error.Types.NotFound)
                    : new ErrorData(type: Error.Types.HasNotPermission));
            }
            foreach (var column in ss.Columns
                     .Where(o => !o.CanCreate(
                                context: context,
                                ss: ss,
                                mine: issueModel.Mine(context: context)))
                     .Where(o => !ss.FormulaTarget(o.ColumnName))
                     .Where(o => !o.Linking))
            {
                switch (column.ColumnName)
                {
                case "Title":
                    if (issueModel.Title_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "Body":
                    if (issueModel.Body_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "WorkValue":
                    if (issueModel.WorkValue_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "ProgressRate":
                    if (issueModel.ProgressRate_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "Status":
                    if (issueModel.Status_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "Manager":
                    if (issueModel.Manager_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "Owner":
                    if (issueModel.Owner_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "Locked":
                    if (issueModel.Locked_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "StartTime":
                    if (issueModel.StartTime_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "CompletionTime":
                    if (issueModel.CompletionTime_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "Comments":
                    if (issueModel.Comments_Updated(context: context))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                default:
                    switch (Def.ExtendedColumnTypes.Get(column.Name))
                    {
                    case "Class":
                        if (issueModel.Class_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;

                    case "Num":
                        if (issueModel.Num_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;

                    case "Date":
                        if (issueModel.Date_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;

                    case "Description":
                        if (issueModel.Description_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;

                    case "Check":
                        if (issueModel.Check_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;

                    case "Attachments":
                        if (issueModel.Attachments_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;
                    }
                    break;
                }
            }
            var errorData = OnAttaching(
                context: context,
                ss: ss,
                issueModel: issueModel);

            if (errorData.Type != Error.Types.None)
            {
                return(errorData);
            }
            var inputErrorData = OnInputValidating(
                context: context,
                ss: ss,
                issueModel: issueModel).FirstOrDefault();

            if (inputErrorData.Type != Error.Types.None)
            {
                return(inputErrorData);
            }
            return(new ErrorData(type: Error.Types.None));
        }
        public static ErrorData OnCreating(
            Context context, SiteSettings ss, IssueModel issueModel, bool api = false)
        {
            if (api && (context.ContractSettings.Api == false || !Parameters.Api.Enabled))
            {
                return(new ErrorData(type: Error.Types.InvalidRequest));
            }
            if (!context.CanCreate(ss: ss))
            {
                return(!context.CanRead(ss: ss)
                    ? new ErrorData(type: Error.Types.NotFound)
                    : new ErrorData(type: Error.Types.HasNotPermission));
            }
            ss.SetColumnAccessControls(context: context, mine: issueModel.Mine(context: context));
            foreach (var column in ss.Columns
                     .Where(o => !o.CanCreate)
                     .Where(o => !ss.FormulaTarget(o.ColumnName))
                     .Where(o => !o.Linking))
            {
                switch (column.ColumnName)
                {
                case "Title":
                    if (issueModel.Title_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "Body":
                    if (issueModel.Body_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "WorkValue":
                    if (issueModel.WorkValue_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "ProgressRate":
                    if (issueModel.ProgressRate_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "Status":
                    if (issueModel.Status_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "Manager":
                    if (issueModel.Manager_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "Owner":
                    if (issueModel.Owner_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "StartTime":
                    if (issueModel.StartTime_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "CompletionTime":
                    if (issueModel.CompletionTime_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "Comments":
                    if (issueModel.Comments_Updated(context: context))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                default:
                    switch (Def.ExtendedColumnTypes.Get(column.Name))
                    {
                    case "Class":
                        if (issueModel.Class_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;

                    case "Num":
                        if (issueModel.Num_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;

                    case "Date":
                        if (issueModel.Date_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;

                    case "Description":
                        if (issueModel.Description_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;

                    case "Check":
                        if (issueModel.Check_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;

                    case "Attachments":
                        if (issueModel.Attachments_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;
                    }
                    break;
                }
            }
            var errorData = OnAttaching(
                context: context,
                ss: ss,
                issueModel: issueModel);

            if (errorData.Type != Error.Types.None)
            {
                return(errorData);
            }
            return(new ErrorData(type: Error.Types.None));
        }