using Oqtane.Models; using System.Net.Http; using System.Threading.Tasks; using System.Collections.Generic; using System.Linq; using Oqtane.Shared; namespace Oqtane.Services { public class TenantService : ServiceBase, ITenantService { private readonly SiteState _siteState; public TenantService(HttpClient http, SiteState siteState) : base(http) { _siteState = siteState; } private string Apiurl => CreateApiUrl(_siteState.Alias, "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}"); } public async Task AddTenantAsync(Tenant tenant) { return await PostJsonAsync(Apiurl, tenant); } public async Task UpdateTenantAsync(Tenant tenant) { return await PutJsonAsync($"{Apiurl}/{tenant.TenantId}", tenant); } public async Task DeleteTenantAsync(int tenantId) { await DeleteAsync($"{Apiurl}/{tenantId}"); } } }