コード例 #1
0
        public static ErrorData OnCreating(
            Context context, SiteSettings ss, TenantModel tenantModel, 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(new ErrorData(type: Error.Types.HasNotPermission));
            }
            ss.SetColumnAccessControls(context: context, mine: tenantModel.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 "TenantName":
                    if (tenantModel.TenantName_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "Title":
                    if (tenantModel.Title_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

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

                case "DisableAllUsersPermission":
                    if (tenantModel.DisableAllUsersPermission_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "DisableStartGuide":
                    if (tenantModel.DisableStartGuide_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "LogoType":
                    if (tenantModel.LogoType_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "HtmlTitleTop":
                    if (tenantModel.HtmlTitleTop_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "HtmlTitleSite":
                    if (tenantModel.HtmlTitleSite_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "HtmlTitleRecord":
                    if (tenantModel.HtmlTitleRecord_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "ContractDeadline":
                    if (tenantModel.ContractDeadline_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

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

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

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

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

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

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

                    case "Attachments":
                        if (tenantModel.Attachments_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;
                    }
                    break;
                }
            }
            return(new ErrorData(type: Error.Types.None));
        }