Example #1
0
        public static void Delete(int fieldId)
        {
            string sqlString = $"DELETE FROM {TableName} WHERE {nameof(FieldInfo.Id)} = @{nameof(FieldInfo.Id)}";

            var parms = new []
            {
                Context.DatabaseApi.GetParameter(nameof(FieldInfo.Id), fieldId)
            };

            Context.DatabaseApi.ExecuteNonQuery(Context.ConnectionString, sqlString, parms);

            FieldItemDao.DeleteByFieldId(fieldId);

            FieldManager.ClearCache();
        }
Example #2
0
        public static void Update(FieldInfo info, bool updateItems)
        {
            var sqlString = $@"UPDATE {TableName} SET
                {nameof(FieldInfo.FormId)} = @{nameof(FieldInfo.FormId)}, 
                {nameof(FieldInfo.Taxis)} = @{nameof(FieldInfo.Taxis)}, 
                {nameof(FieldInfo.Title)} = @{nameof(FieldInfo.Title)},
                {nameof(FieldInfo.Description)} = @{nameof(FieldInfo.Description)},
                {nameof(FieldInfo.PlaceHolder)} = @{nameof(FieldInfo.PlaceHolder)},
                {nameof(FieldInfo.FieldType)} = @{nameof(FieldInfo.FieldType)},
                {nameof(FieldInfo.Validate)} = @{nameof(FieldInfo.Validate)},
                {nameof(FieldInfo.Settings)} = @{nameof(FieldInfo.Settings)}
            WHERE {nameof(FieldInfo.Id)} = @{nameof(FieldInfo.Id)}";

            var updateParms = new []
            {
                Context.DatabaseApi.GetParameter(nameof(FieldInfo.FormId), info.FormId),
                Context.DatabaseApi.GetParameter(nameof(FieldInfo.Taxis), info.Taxis),
                Context.DatabaseApi.GetParameter(nameof(FieldInfo.Title), info.Title),
                Context.DatabaseApi.GetParameter(nameof(FieldInfo.Description), info.Description),
                Context.DatabaseApi.GetParameter(nameof(FieldInfo.PlaceHolder), info.PlaceHolder),
                Context.DatabaseApi.GetParameter(nameof(FieldInfo.FieldType), info.FieldType),
                Context.DatabaseApi.GetParameter(nameof(FieldInfo.Validate), info.Validate),
                Context.DatabaseApi.GetParameter(nameof(FieldInfo.Settings), info.Additional.ToString()),
                Context.DatabaseApi.GetParameter(nameof(FieldInfo.Id), info.Id)
            };

            Context.DatabaseApi.ExecuteNonQuery(Context.ConnectionString, sqlString, updateParms);

            if (updateItems)
            {
                FieldItemDao.DeleteByFieldId(info.Id);
                FieldItemDao.InsertItems(info.FormId, info.Id, info.Items);
            }

            FieldManager.ClearCache();
        }