using Oqtane.Models; using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; using Oqtane.Documentation; using Oqtane.Shared; namespace Oqtane.Services { [PrivateApi("Don't show in the documentation, as everything should use the Interface")] public class UserRoleService : ServiceBase, IUserRoleService { private readonly SiteState _siteState; public UserRoleService(HttpClient http, SiteState siteState) : base(http) { _siteState = siteState; } private string Apiurl => CreateApiUrl("UserRole", _siteState.Alias); public async Task> GetUserRolesAsync(int siteId) { return await GetJsonAsync>($"{Apiurl}?siteid={siteId}"); } public async Task GetUserRoleAsync(int userRoleId) { return await GetJsonAsync($"{Apiurl}/{userRoleId}"); } public async Task AddUserRoleAsync(UserRole userRole) { return await PostJsonAsync(Apiurl, userRole); } public async Task UpdateUserRoleAsync(UserRole userRole) { return await PutJsonAsync($"{Apiurl}/{userRole.UserRoleId}", userRole); } public async Task DeleteUserRoleAsync(int userRoleId) { await DeleteAsync($"{Apiurl}/{userRoleId}"); } } }