public static Error.Types OnCreating(SiteSettings ss, DeptModel deptModel) { if (!ss.CanCreate()) { return(Error.Types.HasNotPermission); } ss.SetColumnAccessControls(deptModel.Mine()); foreach (var column in ss.Columns .Where(o => !o.CanCreate) .Where(o => !ss.FormulaTarget(o.ColumnName)) .Where(o => !o.Linking)) { switch (column.ColumnName) { case "DeptCode": if (deptModel.DeptCode_Updated() && (column.DefaultInput.IsNullOrEmpty() || column.DefaultInput.ToString() != deptModel.DeptCode)) { return(Error.Types.HasNotPermission); } break; case "DeptName": if (deptModel.DeptName_Updated() && (column.DefaultInput.IsNullOrEmpty() || column.DefaultInput.ToString() != deptModel.DeptName)) { return(Error.Types.HasNotPermission); } break; case "Body": if (deptModel.Body_Updated() && (column.DefaultInput.IsNullOrEmpty() || column.DefaultInput.ToString() != deptModel.Body)) { return(Error.Types.HasNotPermission); } break; case "Comments": if (!ss.GetColumn("Comments").CanUpdate) { return(Error.Types.HasNotPermission); } break; } } return(Error.Types.None); }
public static Error.Types OnCreating( IContext context, SiteSettings ss, DeptModel deptModel, bool api = false) { if (api && (context.ContractSettings.Api == false || !Parameters.Api.Enabled)) { return(Error.Types.InvalidRequest); } if (!context.CanCreate(ss: ss)) { return(Error.Types.HasNotPermission); } ss.SetColumnAccessControls(context: context, mine: deptModel.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 "DeptCode": if (deptModel.DeptCode_Updated(context: context, column: column)) { return(Error.Types.HasNotPermission); } break; case "DeptName": if (deptModel.DeptName_Updated(context: context, column: column)) { return(Error.Types.HasNotPermission); } break; case "Body": if (deptModel.Body_Updated(context: context, column: column)) { return(Error.Types.HasNotPermission); } break; case "Comments": if (!ss.GetColumn(context: context, columnName: "Comments").CanUpdate) { return(Error.Types.HasNotPermission); } break; } } return(Error.Types.None); }
public static Error.Types OnUpdating( Context context, SiteSettings ss, DeptModel deptModel) { if (!context.CanUpdate(ss: ss)) { return(Error.Types.HasNotPermission); } ss.SetColumnAccessControls(context: context, mine: deptModel.Mine(context: context)); foreach (var column in ss.Columns .Where(o => !o.CanUpdate) .Where(o => !ss.FormulaTarget(o.ColumnName))) { switch (column.ColumnName) { case "DeptCode": if (deptModel.DeptCode_Updated(context: context)) { return(Error.Types.HasNotPermission); } break; case "DeptName": if (deptModel.DeptName_Updated(context: context)) { return(Error.Types.HasNotPermission); } break; case "Body": if (deptModel.Body_Updated(context: context)) { return(Error.Types.HasNotPermission); } break; case "Comments": if (!ss.GetColumn(context: context, columnName: "Comments").CanUpdate) { return(Error.Types.HasNotPermission); } break; } } return(Error.Types.None); }
public static ErrorData OnCreating( Context context, SiteSettings ss, DeptModel deptModel, 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: deptModel.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 "DeptCode": if (deptModel.DeptCode_Updated(context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "DeptName": if (deptModel.DeptName_Updated(context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Body": if (deptModel.Body_Updated(context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Comments": if (deptModel.Comments_Updated(context: context)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; default: switch (Def.ExtendedColumnTypes.Get(column.Name)) { case "Class": if (deptModel.Class_Updated( columnName: column.Name, context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Num": if (deptModel.Num_Updated( columnName: column.Name, context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Date": if (deptModel.Date_Updated( columnName: column.Name, context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Description": if (deptModel.Description_Updated( columnName: column.Name, context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Check": if (deptModel.Check_Updated( columnName: column.Name, context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Attachments": if (deptModel.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)); }