public async Task <string> CreateBasedTable(CreateBasedTable model) { var queryNotTree = @"CREATE TABLE " + model.TableName + @" ( ID uniqueidentifier, CODE nvarchar(200), NAME nvarchar(200), DATA xml, CREATED datetimeoffset, CREATED_BY uniqueidentifier, MODIFIED datetimeoffset, MODIFIED_BY uniqueidentifier, DESCRIPTION nvarchar(1000), VERSION int, );"; var queryIsTree = @"CREATE TABLE " + model.TableName + @" ( ID uniqueidentifier, CODE nvarchar(200), NAME nvarchar(200), DATA xml, CREATED datetimeoffset, CREATED_BY uniqueidentifier, MODIFIED datetimeoffset, MODIFIED_BY uniqueidentifier, DESCRIPTION nvarchar(1000), VERSION int, INDEX_LEFT int, INDEX_RIGHT int, IS_LEAF int, NODE_LEVEL int, PARENT uniqueidentifier, PATH_CODE nvarchar(1000), PATH_ID nvarchar(1000) );"; var queryCreateBasedTable = model.IsTree ? queryIsTree : queryNotTree; using (var connection = new SqlConnection(_connectionString)) { if (connection.State == ConnectionState.Closed) { connection.Open(); } await connection.ExecuteAsync(queryCreateBasedTable); connection.Close(); return(model.TableName); } }
public async Task <IActionResult> CreateBasedTable(CreateBasedTable model) { var result = await _basedTableRepository.CreateBasedTable(model); return(Ok(new { tableName = result })); }