Include AliasId in service API calls ( this is not needed for interacting with the MasterDB repository however it is needed for tenant-based logging )

This commit is contained in:
Shaun Walker
2020-05-12 20:31:31 -04:00
parent 3efd39c74f
commit 560c995564
6 changed files with 43 additions and 14 deletions

View File

@ -5,16 +5,21 @@ using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
using System; using System;
using Oqtane.Shared;
namespace Oqtane.Services namespace Oqtane.Services
{ {
public class AliasService : ServiceBase, IAliasService public class AliasService : ServiceBase, IAliasService
{ {
public AliasService(HttpClient http) :base(http) { }
private string Apiurl => CreateApiUrl("Alias"); private readonly SiteState _siteState;
public AliasService(HttpClient http, SiteState siteState) : base(http)
{
_siteState = siteState;
}
private string Apiurl => CreateApiUrl(_siteState.Alias, "Alias");
public async Task<List<Alias>> GetAliasesAsync() public async Task<List<Alias>> GetAliasesAsync()
{ {

View File

@ -3,14 +3,20 @@ using System.Threading.Tasks;
using System.Net.Http; using System.Net.Http;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using Oqtane.Shared;
namespace Oqtane.Services namespace Oqtane.Services
{ {
public class JobLogService : ServiceBase, IJobLogService public class JobLogService : ServiceBase, IJobLogService
{ {
public JobLogService(HttpClient http) :base(http) { } private readonly SiteState _siteState;
private string Apiurl => CreateApiUrl("JobLog"); public JobLogService(HttpClient http, SiteState siteState) : base(http)
{
_siteState = siteState;
}
private string Apiurl => CreateApiUrl(_siteState.Alias, "JobLog");
public async Task<List<JobLog>> GetJobLogsAsync() public async Task<List<JobLog>> GetJobLogsAsync()
{ {

View File

@ -3,15 +3,21 @@ using System.Threading.Tasks;
using System.Net.Http; using System.Net.Http;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using Oqtane.Shared;
namespace Oqtane.Services namespace Oqtane.Services
{ {
public class JobService : ServiceBase, IJobService public class JobService : ServiceBase, IJobService
{ {
public JobService(HttpClient http) : base(http) { } private readonly SiteState _siteState;
private string Apiurl => CreateApiUrl("Job"); public JobService(HttpClient http, SiteState siteState) : base(http)
{
_siteState = siteState;
}
private string Apiurl => CreateApiUrl(_siteState.Alias, "Job");
public async Task<List<Job>> GetJobsAsync() public async Task<List<Job>> GetJobsAsync()
{ {
List<Job> jobs = await GetJsonAsync<List<Job>>(Apiurl); List<Job> jobs = await GetJsonAsync<List<Job>>(Apiurl);

View File

@ -135,13 +135,13 @@ namespace Oqtane.Services
//TODO Missing content JSON validation //TODO Missing content JSON validation
} }
// create an API Url which is tenant agnostic ( for use with entities in the MasterDB ) // create an API Url which is tenant agnostic ( for use during installation )
public string CreateApiUrl(string serviceName) public string CreateApiUrl(string serviceName)
{ {
return CreateApiUrl(null, serviceName); return CreateApiUrl(null, serviceName);
} }
// create an API Url which is tenant aware ( for use with entities in the TenantDB ) // create an API Url which is tenant aware ( for use with repositories )
public string CreateApiUrl(Alias alias, string serviceName) public string CreateApiUrl(Alias alias, string serviceName)
{ {
string apiurl = "/"; string apiurl = "/";

View File

@ -1,4 +1,5 @@
using Oqtane.Models; using Oqtane.Models;
using Oqtane.Shared;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -6,9 +7,14 @@ namespace Oqtane.Services
{ {
public class SqlService : ServiceBase, ISqlService public class SqlService : ServiceBase, ISqlService
{ {
public SqlService(HttpClient http) : base(http) { } private readonly SiteState _siteState;
private string Apiurl => CreateApiUrl("Sql"); public SqlService(HttpClient http, SiteState siteState) : base(http)
{
_siteState = siteState;
}
private string Apiurl => CreateApiUrl(_siteState.Alias, "Sql");
public async Task<SqlQuery> ExecuteQueryAsync(SqlQuery sqlquery) public async Task<SqlQuery> ExecuteQueryAsync(SqlQuery sqlquery)
{ {

View File

@ -3,14 +3,20 @@ using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Oqtane.Shared;
namespace Oqtane.Services namespace Oqtane.Services
{ {
public class TenantService : ServiceBase, ITenantService public class TenantService : ServiceBase, ITenantService
{ {
public TenantService(HttpClient http) : base(http) { } private readonly SiteState _siteState;
private string Apiurl => CreateApiUrl("Tenant"); public TenantService(HttpClient http, SiteState siteState) : base(http)
{
_siteState = siteState;
}
private string Apiurl => CreateApiUrl(_siteState.Alias, "Tenant");
public async Task<List<Tenant>> GetTenantsAsync() public async Task<List<Tenant>> GetTenantsAsync()
{ {