Beispiel #1
0
        public static string Update(Context context, SiteSettings ss, int tenantId)
        {
            var tenantModel = new TenantModel(
                context: context, ss: ss, tenantId: tenantId, setByForm: true);
            var invalid = TenantValidators.OnUpdating(
                context: context,
                ss: ss,
                tenantModel: tenantModel);

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

            default: return(invalid.MessageJson(context: context));
            }
            if (tenantModel.AccessStatus != Databases.AccessStatuses.Selected)
            {
                return(Messages.ResponseDeleteConflicts(context: context).ToJson());
            }
            var error = tenantModel.Update(context: context, ss: ss);

            switch (error)
            {
            case Error.Types.None:
                var res = new TenantsResponseCollection(tenantModel);
                return(ResponseByUpdate(res, context, ss, tenantModel)
                       .PrependComment(
                           context: context,
                           ss: ss,
                           column: ss.GetColumn(context: context, columnName: "Comments"),
                           comments: tenantModel.Comments,
                           verType: tenantModel.VerType)
                       .ToJson());

            case Error.Types.UpdateConflicts:
                return(Messages.ResponseUpdateConflicts(
                           context: context,
                           data: tenantModel.Updator.Name)
                       .ToJson());

            default:
                return(error.MessageJson(context: context));
            }
        }