oqtane.framework/Oqtane.Client/Services/SqlService.cs
2020-04-03 17:18:33 -04:00

36 lines
1020 B
C#

using Oqtane.Models;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using Oqtane.Shared;
using System.Collections.Generic;
using System.Linq;
using Oqtane.Services.Interfaces;
namespace Oqtane.Services
{
public class SqlService : ServiceBase, ISqlService
{
private readonly HttpClient _http;
private readonly SiteState _siteState;
private readonly NavigationManager _navigationManager;
public SqlService(HttpClient http, SiteState siteState, NavigationManager navigationManager)
{
_http = http;
_siteState = siteState;
_navigationManager = navigationManager;
}
private string Apiurl
{
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Sql"); }
}
public async Task<SqlQuery> ExecuteQueryAsync(SqlQuery sqlquery)
{
return await _http.PostJsonAsync<SqlQuery>(Apiurl, sqlquery);
}
}
}