public async Task <QueryDeleteResult> Delete(QueryUrn uid, bool force) { logger.LogInformation("Deleting query. Query:{Query}", uid.ToString()); using (var cn = new SqlConnection(dbOpts.ConnectionString)) { await cn.OpenAsync(); try { var dependents = await cn.QueryAsync <QueryDependentRecord>( deleteQuery, new { uid = uid.ToString(), force, user = user.UUID }, commandType : CommandType.StoredProcedure, commandTimeout : dbOpts.DefaultTimeout ); return(QueryDeleteResult.From(dependents.Select(d => { return new QueryDependent(d.Id, QueryUrn.From(d.UniversalId), d.Name, d.Owner); }))); } catch (SqlException se) { logger.LogError("Could not delete query. Query:{Query} Code:{Code} Error:{Error}", uid.ToString(), se.ErrorCode, se.Message); se.MapThrow(); throw; } } }
public async Task <QueryDeleteResult> DeleteAsync(QueryUrn uid, bool force) { using (var cn = new SqlConnection(dbOpts.ConnectionString)) { await cn.OpenAsync(); var dependents = await cn.QueryAsync <QueryDependentRecord>( deleteQuery, new { uid = uid.ToString(), force, user = user.UUID, admin = user.IsAdmin }, commandType : CommandType.StoredProcedure, commandTimeout : dbOpts.DefaultTimeout ); return(QueryDeleteResult.From(dependents.Select(d => { return new QueryDependent(d.Id, QueryUrn.From(d.UniversalId), d.Name, d.Owner); }))); } }