using Oqtane.Models;
using System.Net.Http;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
using Oqtane.Documentation;
using Oqtane.Shared;
namespace Oqtane.Services
{
///
/// Service to manage s on the Oqtane installation.
///
public interface ITenantService
{
///
/// Get all s
///
///
Task> GetTenantsAsync();
///
/// Get one specific
///
/// ID-reference of the
///
Task GetTenantAsync(int tenantId);
}
[PrivateApi("Don't show in the documentation, as everything should use the Interface")]
public class TenantService : ServiceBase, ITenantService
{
public TenantService(HttpClient http, SiteState siteState) : base(http, siteState) { }
private string Apiurl => CreateApiUrl("Tenant");
public async Task> GetTenantsAsync()
{
List tenants = await GetJsonAsync>(Apiurl);
return tenants.OrderBy(item => item.Name).ToList();
}
public async Task GetTenantAsync(int tenantId)
{
return await GetJsonAsync($"{Apiurl}/{tenantId}");
}
}
}