Merge pull request #631 from svreic/bugfix/fixing-theme-service

Fixed ThemeService using tenant aware api calls
This commit is contained in:
Shaun Walker 2020-06-22 16:59:54 -04:00 committed by GitHub
commit e8387103f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,28 +1,26 @@
using Oqtane.Models; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Reflection; using Oqtane.Models;
using System;
using Oqtane.Shared; using Oqtane.Shared;
namespace Oqtane.Services namespace Oqtane.Services
{ {
public class ThemeService : ServiceBase, IThemeService public class ThemeService : ServiceBase, IThemeService
{ {
private readonly HttpClient _http; private readonly SiteState _siteState;
public ThemeService(HttpClient http) : base(http) public ThemeService(HttpClient http, SiteState siteState) : base(http)
{ {
_http = http; _siteState = siteState;
} }
private string Apiurl => CreateApiUrl("Theme"); private string ApiUrl => CreateApiUrl(_siteState.Alias, "Theme");
public async Task<List<Theme>> GetThemesAsync() public async Task<List<Theme>> GetThemesAsync()
{ {
List<Theme> themes = await GetJsonAsync<List<Theme>>(Apiurl); List<Theme> themes = await GetJsonAsync<List<Theme>>(ApiUrl);
return themes.OrderBy(item => item.Name).ToList(); return themes.OrderBy(item => item.Name).ToList();
} }
@ -45,12 +43,12 @@ namespace Oqtane.Services
public async Task InstallThemesAsync() public async Task InstallThemesAsync()
{ {
await GetJsonAsync<List<string>>($"{Apiurl}/install"); await GetJsonAsync<List<string>>($"{ApiUrl}/install");
} }
public async Task DeleteThemeAsync(string themeName) public async Task DeleteThemeAsync(string themeName)
{ {
await DeleteAsync($"{Apiurl}/{themeName}"); await DeleteAsync($"{ApiUrl}/{themeName}");
} }
} }
} }